Basic Knowledge
Essential knowledge articles on Rules SDK
Utility Bundles Overview
Essential knowledgeThe Fluent Commerce Utility Bundles are a set of libraries designed to accelerate Rule development, reduce boilerplate code, and improve the overall quality and maintainability of implementations. They are the cornerstone of writing maintainable, reusable, and easily upgradeable Rules for the Fluent Commerce platform.- Prerequisites: You should have knowledge of the Rules SDK, including Designing Rules, Rule Structure, Writing Rules, Rule Development Guidelines, General Principles, and Rules SDK - Getting Started.
- Focus on Business Logic: The libraries handle common, repetitive tasks (like data fetching and JSON conversion), allowing developers to concentrate on writing the business logic that delivers value.
- Three Specialized Bundles: The utilities are organized into three modules:
`util-core` for essential daily tasks, `util-dynamic` for building runtime queries, and `util-test` for simplifying testing. - Easy Upgrades: Receive bug fixes and new features from Fluent Commerce by updating the dependency version in your
`pom.xml`, ensuring your implementation stays current. - Built for Extensibility: The utilities are designed to be flexible, allowing you to inject your custom logic into standard processes.
MockApiClient
Essential knowledgeThe `MockApiClient` is a critical component of the `util-test` library. It provides a mock implementation of the `ApiClient`, which is the interface Rules use to communicate with the Fluent Commerce GraphQL API.By using the `MockApiClient`, you can test how your Rule behaves with different API responses without making any actual network calls. This isolates your tests, makes them faster, and allows you to simulate any scenario, including errors or empty data results.
- Test API Interactions: The
`MockApiClient` allows you to test how your rule responds to different API outcomes (e.g., success, failure, empty data) without making live network calls. - Isolate and Speed Up Tests: By mocking the API, your tests run faster and are isolated from network or environment issues.
- Executor Integration: You typically don't use
`MockApiClient` directly. You use the helper methods on `RuleExecutor` and `WorkflowExecutor` (like `.mockQuery()` and `.mockSetting()`) to configure it. - Full Coverage: It supports mocking pre-compiled queries/mutations, dynamic queries/mutations, and settings, giving you complete control over your test environment.