Skip to content

Test coverage for JSONCondition getMostRecentHistoricalEvent (search type mostRecent)#1140

Merged
timkimadobe merged 4 commits intoadobe:feature/historical-consequencefrom
timkimadobe:requalification-tests
May 29, 2025
Merged

Test coverage for JSONCondition getMostRecentHistoricalEvent (search type mostRecent)#1140
timkimadobe merged 4 commits intoadobe:feature/historical-consequencefrom
timkimadobe:requalification-tests

Conversation

@timkimadobe
Copy link
Copy Markdown
Contributor

@timkimadobe timkimadobe commented Apr 30, 2025

Important

This PR is based on the implementation of mostRecent in (and this diff currently also contains its changes):

Once #1138 is merged, this PR should reflect the actual scope of changes.

Description

This PR adds test coverage for the new mostRecent search type in rules historical conditions.

JSONConditionMostRecentTests (new!)

  • Creates a base JSONCondition whose getMostRecentHistoricalEvent can be tested
  • Tests invalid inputs and validates they return -1
  • Tests correct cases, validating:
    • No matching events returns -1
    • Returns 0 when there's a single result with a valid timestamp
    • Returns the index of the most recent event when two results differ in date
    • Prioritizes the most recent date even if another result has a higher count
    • Correctly returns the index of the newest result when entries are out of order
    • Returns the first index when multiple results have identical timestamps

RulesEngineFunctionalTests

  • Added two cases which test the mostRecent condition in a consequence correctly evaluating to:
    • Pass and dispatch a consequence event
    • Fail and not dispatch a consequence event

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@timkimadobe timkimadobe changed the title Test coverage for mostRecent search type for rules historical condition Test coverage for JSONCondition getMostRecentHistoricalEvent (search type mostRecent) May 1, 2025
@timkimadobe timkimadobe merged commit 1bb0bda into adobe:feature/historical-consequence May 29, 2025
17 checks passed
@timkimadobe timkimadobe deleted the requalification-tests branch May 29, 2025 20:26
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.

2 participants