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

feat: script execution after rule extraction #21

Merged
merged 4 commits into from
Mar 12, 2024

Conversation

andrea-deri
Copy link
Contributor

@andrea-deri andrea-deri commented Mar 5, 2024

This PR contains a major feature made on Mocker system that provide the possibility to add dynamic logic during mocking process. This feature allows the execution of custom scripts when a specific mock rule occurs. For doing so, it is only needed to set the reference of the required script (and the input parameters which may be static or variable) to the mock rule on which the business logic is to be bound.

List of Changes

  • Added new special subsystem that permits to load all scripts at startup and execute them when mock rule with script occurs
  • Added dedicated entity that maps the collection used for store script code to be executed by engine
  • Added information on MockRuleEntity that permits to refers to script code to be executed in runtime
  • Added dependency for OpenJDK's Nashorn script engine
  • Generalized SpecialRequestHeaderEntity entity in order to be used as a key-value pair for all needs
  • Updated parameter injection in response body in order to also permits the injection of script-returned response fields.

Motivation and Context

This modification broadens the use cases in which Mocker can be used, adding dynamic logic that can simplify and add expressiveness to tests.

How Has This Been Tested?

  • Tested in local environment
  • Tested in DEV environment

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 not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@andrea-deri andrea-deri self-assigned this Mar 5, 2024
@andrea-deri andrea-deri requested a review from a team as a code owner March 5, 2024 21:15
Copy link

Comment this PR with update_code to format the code. Consider to use pre-commit to format the code.

@andrea-deri andrea-deri merged commit a8f7c65 into main Mar 12, 2024
1 check passed
@andrea-deri andrea-deri deleted the feat-scripting-on-mock-rule branch March 12, 2024 13:24
andrea-deri added a commit to pagopa/pagopa-mocker-config that referenced this pull request Mar 12, 2024
This PR permits to handle the configuration of business logic execution using dedicated scripts.  
The main information about the logic is defined in [this PR](pagopa/pagopa-mocker#21), this one is related only to the configuration APIs that includes the new information in the existing interfaces.

#### List of Changes
 - Updated interface and persistence logic, including references to scripting binding
 - Added dedicated entity that maps the collection used for store script code to be executed by engine
 - Added information on `MockRuleEntity` that permits to refers to script code to be executed in runtime
 - Added new API for retrieve all script metadata that can be assigned to mock rule
andrea-deri added a commit to pagopa/pagopa-shared-toolbox that referenced this pull request Mar 12, 2024
This PR adds the configuration of a new feature on Mocker configurator in order to handle the configuration of business logic execution using dedicated scripts. The main information about the logic is defined in [this PR](pagopa/pagopa-mocker#21).  
This new functionality is added:
 - as new visible information in mock resource view, for each mock rule that uses the scripting logic
 - as configurable feature either in edit and add mock rule pages 

#### List of Changes
 - Added information about bound script for each mock rule that uses it
 - Added section on new/edit mock rule that permits to bind script to a mock rule
 - Added explicative tooltips on other fields
 - Several other little fixes and improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants