-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Validate only when first event and no rule match - Add more tests
- Loading branch information
Showing
12 changed files
with
29,023 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
232 changes: 174 additions & 58 deletions
232
.../java/org/drools/ansible/rulebook/integration/api/rulesengine/RulesSetEventStructure.java
Large diffs are not rendered by default.
Oops, something went wrong.
454 changes: 450 additions & 4 deletions
454
...c/test/java/org/drools/ansible/rulebook/integration/api/EventStructureSuggestionTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
...est/java/org/drools/ansible/rulebook/integration/api/rulesengine/RuleEngineTestUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.drools.ansible.rulebook.integration.api.rulesengine; | ||
|
||
public class RuleEngineTestUtils { | ||
|
||
private RuleEngineTestUtils() { | ||
// Utility class | ||
} | ||
|
||
public static void enableEventStructureSuggestion() { | ||
RulesSetEventStructure.EVENT_STRUCTURE_SUGGESTION_ENABLED = true; | ||
} | ||
|
||
public static void disableEventStructureSuggestion() { | ||
RulesSetEventStructure.EVENT_STRUCTURE_SUGGESTION_ENABLED = false; | ||
} | ||
} |
148 changes: 148 additions & 0 deletions
148
drools-ansible-rulebook-integration-api/src/test/resources/github-event.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
{ | ||
"hook": { | ||
"active": true, | ||
"config": { | ||
"content_type": "json", | ||
"insecure_ssl": "1", | ||
"secret": "********", | ||
"url": "https://198.51.100.42/eda-event-streams/api/eda/v1/external_event_stream/a1b2c3d4-e5f6-7a8b-9c0d-1234e56789ab/post/" | ||
}, | ||
"created_at": "2024-09-24T09:14:14Z", | ||
"deliveries_url": "https://api.github.com/repos/johndoeeda/eda-project/hooks/123456789/deliveries", | ||
"events": ["push"], | ||
"id": 123456789, | ||
"last_response": { | ||
"code": null, | ||
"message": null, | ||
"status": "unused" | ||
}, | ||
"name": "web", | ||
"ping_url": "https://api.github.com/repos/johndoeeda/eda-project/hooks/123456789/pings", | ||
"test_url": "https://api.github.com/repos/johndoeeda/eda-project/hooks/123456789/test", | ||
"type": "Repository", | ||
"updated_at": "2024-09-24T09:14:14Z", | ||
"url": "https://api.github.com/repos/johndoeeda/eda-project/hooks/123456789" | ||
}, | ||
"hook_id": 123456789, | ||
"repository": { | ||
"allow_forking": true, | ||
"archive_url": "https://api.github.com/repos/johndoeeda/eda-project/{archive_format}{/ref}", | ||
"archived": false, | ||
"assignees_url": "https://api.github.com/repos/johndoeeda/eda-project/assignees{/user}", | ||
"blobs_url": "https://api.github.com/repos/johndoeeda/eda-project/git/blobs{/sha}", | ||
"branches_url": "https://api.github.com/repos/johndoeeda/eda-project/branches{/branch}", | ||
"clone_url": "https://github.com/johndoeeda/eda-project.git", | ||
"collaborators_url": "https://api.github.com/repos/johndoeeda/eda-project/collaborators{/collaborator}", | ||
"comments_url": "https://api.github.com/repos/johndoeeda/eda-project/comments{/number}", | ||
"commits_url": "https://api.github.com/repos/johndoeeda/eda-project/commits{/sha}", | ||
"compare_url": "https://api.github.com/repos/johndoeeda/eda-project/compare/{base}...{head}", | ||
"contents_url": "https://api.github.com/repos/johndoeeda/eda-project/contents/{+path}", | ||
"contributors_url": "https://api.github.com/repos/johndoeeda/eda-project/contributors", | ||
"created_at": "2023-04-10T18:30:32Z", | ||
"default_branch": "main", | ||
"deployments_url": "https://api.github.com/repos/johndoeeda/eda-project/deployments", | ||
"description": null, | ||
"disabled": false, | ||
"downloads_url": "https://api.github.com/repos/johndoeeda/eda-project/downloads", | ||
"events_url": "https://api.github.com/repos/johndoeeda/eda-project/events", | ||
"fork": true, | ||
"forks": 2, | ||
"forks_count": 2, | ||
"forks_url": "https://api.github.com/repos/johndoeeda/eda-project/forks", | ||
"full_name": "johndoeeda/eda-project", | ||
"git_commits_url": "https://api.github.com/repos/johndoeeda/eda-project/git/commits{/sha}", | ||
"git_refs_url": "https://api.github.com/repos/johndoeeda/eda-project/git/refs{/sha}", | ||
"git_tags_url": "https://api.github.com/repos/johndoeeda/eda-project/git/tags{/sha}", | ||
"git_url": "git://github.com/johndoeeda/eda-project.git", | ||
"has_discussions": false, | ||
"has_downloads": true, | ||
"has_issues": false, | ||
"has_pages": false, | ||
"has_projects": true, | ||
"has_wiki": true, | ||
"homepage": null, | ||
"hooks_url": "https://api.github.com/repos/johndoeeda/eda-project/hooks", | ||
"html_url": "https://github.com/johndoeeda/eda-project", | ||
"id": 987654321, | ||
"is_template": false, | ||
"issue_comment_url": "https://api.github.com/repos/johndoeeda/eda-project/issues/comments{/number}", | ||
"issue_events_url": "https://api.github.com/repos/johndoeeda/eda-project/issues/events{/number}", | ||
"issues_url": "https://api.github.com/repos/johndoeeda/eda-project/issues{/number}", | ||
"keys_url": "https://api.github.com/repos/johndoeeda/eda-project/keys{/key_id}", | ||
"labels_url": "https://api.github.com/repos/johndoeeda/eda-project/labels{/name}", | ||
"language": "Dockerfile", | ||
"languages_url": "https://api.github.com/repos/johndoeeda/eda-project/languages", | ||
"license": null, | ||
"merges_url": "https://api.github.com/repos/johndoeeda/eda-project/merges", | ||
"milestones_url": "https://api.github.com/repos/johndoeeda/eda-project/milestones{/number}", | ||
"mirror_url": null, | ||
"name": "eda-project", | ||
"node_id": "ABC123DEF456", | ||
"notifications_url": "https://api.github.com/repos/johndoeeda/eda-project/notifications{?since,all,participating}", | ||
"open_issues": 0, | ||
"open_issues_count": 0, | ||
"owner": { | ||
"avatar_url": "https://avatars.githubusercontent.com/u/1234567?v=4", | ||
"events_url": "https://api.github.com/users/johndoeeda/events{/privacy}", | ||
"followers_url": "https://api.github.com/users/johndoeeda/followers", | ||
"following_url": "https://api.github.com/users/johndoeeda/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/johndoeeda/gists{/gist_id}", | ||
"gravatar_id": "", | ||
"html_url": "https://github.com/johndoeeda", | ||
"id": 1234567, | ||
"login": "johndoeeda", | ||
"node_id": "XYZ789LMN012", | ||
"organizations_url": "https://api.github.com/users/johndoeeda/orgs", | ||
"received_events_url": "https://api.github.com/users/johndoeeda/received_events", | ||
"repos_url": "https://api.github.com/users/johndoeeda/repos", | ||
"site_admin": false, | ||
"starred_url": "https://api.github.com/users/johndoeeda/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/johndoeeda/subscriptions", | ||
"type": "User", | ||
"url": "https://api.github.com/users/johndoeeda" | ||
}, | ||
"private": false, | ||
"pulls_url": "https://api.github.com/repos/johndoeeda/eda-project/pulls{/number}", | ||
"pushed_at": "2024-08-31T15:52:21Z", | ||
"releases_url": "https://api.github.com/repos/johndoeeda/eda-project/releases{/id}", | ||
"size": 107, | ||
"ssh_url": "[email protected]:johndoeeda/eda-project.git", | ||
"stargazers_count": 0, | ||
"stargazers_url": "https://api.github.com/repos/johndoeeda/eda-project/stargazers", | ||
"statuses_url": "https://api.github.com/repos/johndoeeda/eda-project/statuses/{sha}", | ||
"subscribers_url": "https://api.github.com/repos/johndoeeda/eda-project/subscribers", | ||
"subscription_url": "https://api.github.com/repos/johndoeeda/eda-project/subscription", | ||
"svn_url": "https://github.com/johndoeeda/eda-project", | ||
"tags_url": "https://api.github.com/repos/johndoeeda/eda-project/tags", | ||
"teams_url": "https://api.github.com/repos/johndoeeda/eda-project/teams", | ||
"topics": [], | ||
"trees_url": "https://api.github.com/repos/johndoeeda/eda-project/git/trees{/sha}", | ||
"updated_at": "2024-08-31T15:52:24Z", | ||
"url": "https://api.github.com/repos/johndoeeda/eda-project", | ||
"visibility": "public", | ||
"watchers": 0, | ||
"watchers_count": 0, | ||
"web_commit_signoff_required": false | ||
}, | ||
"sender": { | ||
"avatar_url": "https://avatars.githubusercontent.com/u/1234567?v=4", | ||
"events_url": "https://api.github.com/users/johndoeeda/events{/privacy}", | ||
"followers_url": "https://api.github.com/users/johndoeeda/followers", | ||
"following_url": "https://api.github.com/users/johndoeeda/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/johndoeeda/gists{/gist_id}", | ||
"gravatar_id": "", | ||
"html_url": "https://github.com/johndoeeda", | ||
"id": 1234567, | ||
"login": "johndoeeda", | ||
"node_id": "XYZ789LMN012", | ||
"organizations_url": "https://api.github.com/users/johndoeeda/orgs", | ||
"received_events_url": "https://api.github.com/users/johndoeeda/received_events", | ||
"repos_url": "https://api.github.com/users/johndoeeda/repos", | ||
"site_admin": false, | ||
"starred_url": "https://api.github.com/users/johndoeeda/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/johndoeeda/subscriptions", | ||
"type": "User", | ||
"url": "https://api.github.com/users/johndoeeda" | ||
}, | ||
"zen": "Accessible for all." | ||
} |
153 changes: 153 additions & 0 deletions
153
drools-ansible-rulebook-integration-api/src/test/resources/gitlab-event.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
{ | ||
"after": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0", | ||
"before": "p0o9n8m7l6k5j4i3h2g1f0e9d8c7b6a5a4b3c2d1", | ||
"checkout_sha": null, | ||
"commits": [ | ||
{ | ||
"added": [ | ||
"extensions/eda/multiple_conditions_job_template.not_work", | ||
"extensions/eda/rulebooks/100_million_events.yml", | ||
"extensions/eda/rulebooks/10_job_template.yml", | ||
"extensions/eda/rulebooks/10_million_events.yml", | ||
"extensions/eda/rulebooks/10_minute.yml", | ||
"extensions/eda/rulebooks/46_job_template.yml", | ||
"extensions/eda/rulebooks/80_match_multiple_rules.yml", | ||
"extensions/eda/rulebooks/all_conditions.yml", | ||
"extensions/eda/rulebooks/artifacts_job_template.yml", | ||
"extensions/eda/rulebooks/bad_job_template.yml", | ||
"extensions/eda/rulebooks/basic_job_template.yml", | ||
"extensions/eda/rulebooks/blob_generator.yml", | ||
"extensions/eda/rulebooks/fail_job_template.yml", | ||
"extensions/eda/rulebooks/first_rule.yml", | ||
"extensions/eda/rulebooks/fouth_rule.yml", | ||
"extensions/eda/rulebooks/generic_webhook_listener.yml", | ||
"extensions/eda/rulebooks/kafka_event_router.yml", | ||
"extensions/eda/rulebooks/kafka_generator.yml", | ||
"extensions/eda/rulebooks/kafka_jinja.yml", | ||
"extensions/eda/rulebooks/kafka_listener.yml", | ||
"extensions/eda/rulebooks/limits_with_jinja.yml", | ||
"extensions/eda/rulebooks/limits_with_vault_secret.yml", | ||
"extensions/eda/rulebooks/listener.yml", | ||
"extensions/eda/rulebooks/listener_no_shutdown.yml", | ||
"extensions/eda/rulebooks/million_events.yml", | ||
"extensions/eda/rulebooks/missing_source.yml", | ||
"extensions/eda/rulebooks/multiple_conditions_job_template.yml", | ||
"extensions/eda/rulebooks/multiple_rules_with_sleep.yml", | ||
"extensions/eda/rulebooks/multiple_source_job_template.yml", | ||
"extensions/eda/rulebooks/new_pg_notify_template.yml", | ||
"extensions/eda/rulebooks/pg_demo_.yml", | ||
"extensions/eda/rulebooks/pg_event_stream_rulebook.yml", | ||
"extensions/eda/rulebooks/pg_notify_template.yml", | ||
"extensions/eda/rulebooks/pgnotify_with_configurable_blob.yml", | ||
"extensions/eda/rulebooks/print_rulebook_events.yml", | ||
"extensions/eda/rulebooks/repeater.yml", | ||
"extensions/eda/rulebooks/rule_with_pipe.yml", | ||
"extensions/eda/rulebooks/rulebook_with_configurable_blob.yml", | ||
"extensions/eda/rulebooks/rules_every_minute.yml", | ||
"extensions/eda/rulebooks/rules_in_flux.yml", | ||
"extensions/eda/rulebooks/rules_with_facts.yml", | ||
"extensions/eda/rulebooks/same_rule_names1.yml", | ||
"extensions/eda/rulebooks/same_rule_names2.yml", | ||
"extensions/eda/rulebooks/same_rule_names3.yml", | ||
"extensions/eda/rulebooks/second_rule.yml", | ||
"extensions/eda/rulebooks/should_fail_import.yml", | ||
"extensions/eda/rulebooks/single_rule.yml", | ||
"extensions/eda/rulebooks/single_rule_jinja.yml", | ||
"extensions/eda/rulebooks/single_rule_with_vaulted_strings.yml", | ||
"extensions/eda/rulebooks/test_mem.yml", | ||
"extensions/eda/rulebooks/test_webhook.yml", | ||
"extensions/eda/rulebooks/test_webhook_6666.yml", | ||
"extensions/eda/rulebooks/test_webhook_with_var.yml", | ||
"extensions/eda/rulebooks/third_rule.yml", | ||
"extensions/eda/rulebooks/utf_key.yml", | ||
"extensions/eda/rulebooks/vault_demo1.yml", | ||
"extensions/eda/rulebooks/webhook_log_all.yml", | ||
"extensions/eda/rulebooks/webhook_repeater.yml", | ||
"extensions/eda/rulebooks/webhook_repeater_no_shutdown.yml", | ||
"extensions/eda/rulebooks/webhook_repeater_with_debug.yml", | ||
"extensions/eda/rulebooks/webhook_rulebook_barney.yml", | ||
"extensions/eda/rulebooks/webhook_rulebook_fred.yml", | ||
"extensions/eda/rulebooks/webhook_rulebook_wilma.yml" | ||
], | ||
"author": { | ||
"email": "[email protected]", | ||
"name": "John Doe" | ||
}, | ||
"id": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0", | ||
"message": "moved to extensions/eda/rulebooks\n\n", | ||
"modified": [], | ||
"removed": [], | ||
"timestamp": "2024-03-14T14:37:04-04:00", | ||
"title": "moved to extensions/eda/rulebooks", | ||
"url": "https://gitlab.cee.example.com/johndoe/eda-sample-project/-/commit/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0" | ||
}, | ||
{ | ||
"added": ["rulebooks/limits_with_vault_secret.yml"], | ||
"author": { | ||
"email": "[email protected]", | ||
"name": "John Doe" | ||
}, | ||
"id": "b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0a1", | ||
"message": "secret in limit\n\n", | ||
"modified": [], | ||
"removed": [], | ||
"timestamp": "2024-03-12T15:58:04-04:00", | ||
"title": "secret in limit", | ||
"url": "https://gitlab.cee.example.com/johndoe/eda-sample-project/-/commit/b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0a1" | ||
}, | ||
{ | ||
"added": ["rulebooks/kafka_jinja.yml"], | ||
"author": { | ||
"email": "[email protected]", | ||
"name": "John Doe" | ||
}, | ||
"id": "c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0a1b2", | ||
"message": "added kafka jinja\n\n", | ||
"modified": [], | ||
"removed": [], | ||
"timestamp": "2024-03-09T18:38:47-05:00", | ||
"title": "added kafka jinja", | ||
"url": "https://gitlab.cee.example.com/johndoe/eda-sample-project/-/commit/c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0a1b2" | ||
} | ||
], | ||
"event_name": "tag_push", | ||
"message": null, | ||
"object_kind": "tag_push", | ||
"project": { | ||
"avatar_url": null, | ||
"ci_config_path": "", | ||
"default_branch": "main", | ||
"description": null, | ||
"git_http_url": "https://gitlab.cee.example.com/johndoe/eda-sample-project.git", | ||
"git_ssh_url": "[email protected]:johndoe/eda-sample-project.git", | ||
"homepage": "https://gitlab.cee.example.com/johndoe/eda-sample-project", | ||
"http_url": "https://gitlab.cee.example.com/johndoe/eda-sample-project.git", | ||
"id": 88440, | ||
"name": "EDA Sample Project", | ||
"namespace": "John Doe", | ||
"path_with_namespace": "johndoe/eda-sample-project", | ||
"ssh_url": "[email protected]:johndoe/eda-sample-project.git", | ||
"url": "[email protected]:johndoe/eda-sample-project.git", | ||
"visibility_level": 20, | ||
"web_url": "https://gitlab.cee.example.com/johndoe/eda-sample-project" | ||
}, | ||
"project_id": 88440, | ||
"push_options": {}, | ||
"ref": "refs/tags/v1.0.0", | ||
"ref_protected": false, | ||
"repository": { | ||
"description": null, | ||
"git_http_url": "https://gitlab.cee.example.com/johndoe/eda-sample-project.git", | ||
"git_ssh_url": "[email protected]:johndoe/eda-sample-project.git", | ||
"homepage": "https://gitlab.cee.example.com/johndoe/eda-sample-project", | ||
"name": "EDA Sample Project", | ||
"url": "[email protected]:johndoe/eda-sample-project.git", | ||
"visibility_level": 20 | ||
}, | ||
"total_commits_count": 3, | ||
"user_avatar": "https://seccdn.example.org/avatar/9e4f1b268b2b00d90d526a603e19423efdd19cb3878d43d86ea5e5eceb1b2b9d?s=80&d=identicon", | ||
"user_email": "[email protected]", | ||
"user_id": 9135, | ||
"user_name": "John Doe", | ||
"user_username": "johndoe" | ||
} |
Oops, something went wrong.