Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Adding logging to save others in the future (#1055)
Browse files Browse the repository at this point in the history
* Adding logging to save others in the future

* Adding dependency injection for test
  • Loading branch information
jcrichlake authored May 1, 2024
1 parent 33f43d8 commit 0ee7342
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import gov.hhs.cdc.trustedintermediary.etor.RSEndpointClient;
import gov.hhs.cdc.trustedintermediary.external.reportstream.ReportStreamEndpointClientException;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.UUID;
import javax.inject.Inject;

/**
* A mock implementation of the RSEndpointClient interface that doesn't require a connection to
Expand All @@ -18,6 +20,8 @@ public class MockRSEndpointClient implements RSEndpointClient {

private static final MockRSEndpointClient INSTANCE = new MockRSEndpointClient();

@Inject Logger logger;

public static MockRSEndpointClient getInstance() {
return INSTANCE;
}
Expand All @@ -38,6 +42,10 @@ public String requestWatersEndpoint(String body, String bearerToken)
} catch (IOException e) {
throw new ReportStreamEndpointClientException("Error writing the lab order", e);
}

logger.logWarning(
"!@#$%^&*() THE BELOW REPORT ID is RaNdOmLy generated and will not populate into report stream !@#$%^&*()");

return "{ \"reportId\": \"" + UUID.randomUUID() + "\" }";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class MockRSEndpointClientTest extends Specification {
def setup() {
TestApplicationContext.reset()
TestApplicationContext.init()
TestApplicationContext.register(MockRSEndpointClient, MockRSEndpointClient.getInstance())
TestApplicationContext.injectRegisteredImplementations()
}

def cleanup() {
Expand Down

0 comments on commit 0ee7342

Please sign in to comment.