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

DMP-4674: Log courthouse not found error on addAudio for Dyntrace #2517

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Ben-Edwards-cgi
Copy link
Contributor

Links

Jira

Change description

Summary of Git Diff

This Git diff introduces enhancements to the AddAudioMetaDataValidator and related classes in a Java application. The primary change is the addition of error handling and logging for cases where a specified courthouse does not exist. The updates also include modifications to the AudioLoggerService to support this new logging functionality and the creation of corresponding unit tests to verify the behavior.

Highlights

  • Error Handling:

    • A try-catch block has been added in the validate method of the AddAudioMetaDataValidator class to catch DartsApiException when retrieving the courthouse.
    • If the exception indicates that the courthouse does not exist, a log entry is created using the AudioLoggerService.
  • New Logging Method:

    • A new method, missingCourthouse, has been added to the AudioLoggerService interface and its implementation to log warnings when a courthouse is not found.
  • Unit Tests:

    • A new test class AddAudioMetaDataValidatorTest is introduced to validate the behavior of the AddAudioMetaDataValidator.
    • Tests are included to ensure that when a nonexistent courthouse is specified, the correct exception is thrown and the logging method is invoked.
    • Additional tests confirm that valid courthouse requests do not trigger logging.
  • Code Structure:

    • The AudioLoggerServiceImpl is modified to include a Clock for timestamping log entries.

These changes improve the robustness of the audio metadata validation process by ensuring that invalid input is logged appropriately, aiding both debugging and system monitoring.

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[X] No

@Ben-Edwards-cgi Ben-Edwards-cgi requested review from a team as code owners January 30, 2025 15:09
@Ben-Edwards-cgi Ben-Edwards-cgi requested review from davet1985, jackmaloney, cakeben, jordankainos, danielwilsonkainos and ieuanb74 and removed request for a team January 30, 2025 15:09
public class AudioLoggerServiceImpl implements AudioLoggerService {

private final Clock clock;
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought it was agreed we wouldn't introduce clock as it creates inconsistent coding standards?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding was we needed a follow up call as I took an action to confirm some things. I have updated the logic so the clock stuff is simpler.

We already have inconsistencies as some places use clock some use currentTimeHelper

Copy link
Contributor

Choose a reason for hiding this comment

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

There are only 2 production classes using clock. The rest all use the CurrentTimeHelper.

Copy link
Contributor

Choose a reason for hiding this comment

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

Both instances where they have been introduced have been within the last 2 weeks. Can we try and use one pattern until a decision is actually made to use one over the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the logic to use currentTimeHelper

@@ -44,7 +45,7 @@ public static void tearDown() {

@BeforeEach
void setUp() {
audioLoggerService = new AudioLoggerServiceImpl();
audioLoggerService = new AudioLoggerServiceImpl(Clock.fixed(STARTED_AT.toInstant(), STARTED_AT.toZonedDateTime().getZone()));
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment about use of clock

Copy link
Contributor

@jackmaloney jackmaloney left a comment

Choose a reason for hiding this comment

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

The ticket mentions changing the message in the EventLoggerServiceImpl which doesn't look like has been done as part of this, please can you add?

@@ -14,12 +15,14 @@
@RequiredArgsConstructor
public class CurrentTimeHelper {

private final Clock clock;
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this change actually give us and why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It grants us much greater flexibility in adjusting dates/times without needing to utilise mocks in integration tests. (and ensures we are following industry standards for date/time operations)

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

Successfully merging this pull request may close these issues.

3 participants