%dw 2.8
import * from dw::test::Asserts
import * from dw::test::Tests
import * from dw::Runtime
import * from com::mulesoft::connectivity::Model
import * from com::mulesoft::connectivity::transport::Http
import * from com::mulesoft::connectivity::Metadata
import * from utils::ConnectionOperations
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars_post
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__get
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__patch
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__delete
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__acl_post
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__acl_get
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__acl__ruleId__get
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__acl__ruleId__patch
import * from com::mulesoft::connectivity::zzz4::operations::O_calendars__calendarId__acl__ruleId__delete
import * from data::calendars_post_request
import * from data::calendars__calendarId__get_request
import * from data::calendars__calendarId__patch_request
import * from data::calendars__calendarId__delete_request
import * from data::calendars__calendarId__acl_post_request
import * from data::calendars__calendarId__acl_get_request
import * from data::calendars__calendarId__acl__ruleId__get_request
import * from data::calendars__calendarId__acl__ruleId__patch_request
import * from data::calendars__calendarId__acl__ruleId__delete_request
var V_calendars_post_response = O_calendars_post.executor(V_calendars_post_request(), connection)
var V_calendars__calendarId__get_response = O_calendars__calendarId__get.executor(V_calendars__calendarId__get_request(CALENDARID), connection)
var V_calendars__calendarId__patch_response = O_calendars__calendarId__patch.executor(V_calendars__calendarId__patch_request(CALENDARID), connection)
var V_calendars__calendarId__delete_response = O_calendars__calendarId__delete.executor(V_calendars__calendarId__delete_request(CALENDARID), connection)
var V_calendars__calendarId__acl_post_response = O_calendars__calendarId__acl_post.executor(V_calendars__calendarId__acl_post_request(CALENDARID), connection)
var V_calendars__calendarId__acl_get_response = O_calendars__calendarId__acl_get.executor(V_calendars__calendarId__acl_get_request(CALENDARID), connection)
var V_calendars__calendarId__acl__ruleId__get_response = O_calendars__calendarId__acl__ruleId__get.executor(V_calendars__calendarId__acl__ruleId__get_request(CALENDARID,RULEID), connection)
var V_calendars__calendarId__acl__ruleId__patch_response = O_calendars__calendarId__acl__ruleId__patch.executor(V_calendars__calendarId__acl__ruleId__patch_request(CALENDARID,RULEID), connection)
var V_calendars__calendarId__acl__ruleId__delete_response = O_calendars__calendarId__acl__ruleId__delete.executor(V_calendars__calendarId__acl__ruleId__delete_request(CALENDARID,RULEID), connection)
---
"/calendars/{calendarId}/acl/{ruleId} tests" describedBy [
"/calendars - POST Successful Execution" in do {
V_calendars_post_response.value.status must equalTo(200)
},
"/calendars/{calendarId} - GET Successful Execution" in do {
V_calendars__calendarId__get_response.value.status must equalTo(200)
},
"/calendars/{calendarId} - PATCH Successful Execution" in do {
V_calendars__calendarId__patch_response.value.status must equalTo(200)
},
"/calendars/{calendarId} - DELETE Successful Execution" in do {
V_calendars__calendarId__delete_response.value.status must equalTo(200)
},
"/calendars/{calendarId}/acl - POST Successful Execution" in do {
V_calendars__calendarId__acl_post_response.value.status must equalTo(200)
},
"/calendars/{calendarId}/acl - GET Successful Execution" in do {
V_calendars__calendarId__acl_get_response.value.status must equalTo(200)
},
"/calendars/{calendarId}/acl/{ruleId} - GET Successful Execution" in do {
V_calendars__calendarId__acl__ruleId__get_response.value.status must equalTo(200)
},
"/calendars/{calendarId}/acl/{ruleId} - PATCH Successful Execution" in do {
V_calendars__calendarId__acl__ruleId__patch_response.value.status must equalTo(200)
},
"/calendars/{calendarId}/acl/{ruleId} - DELETE Successful Execution" in do {
V_calendars__calendarId__acl__ruleId__delete_response.value.status must equalTo(200)
},
]
Testing Connectors
Learn how to test your connector. Testing is an important part of the development process, and it helps you ensure that your connector works as expected. Testing your connector involves generating tests, running tests, and validating the connector within the platform.
Generate Tests (Beta)
| Generating tests is a pilot or beta service that is subject to the Beta Services Terms at Agreements - Salesforce.com or a written Unified Pilot Agreement if executed by Customer, and applicable terms in the Product Terms Directory. Use of this pilot or beta service is at the Customer’s sole discretion. |
You can generate tests without AI assistance, with AI assistance (available when using Cursor), or with MCP tools (available when using Cursor). Tests are generated for the modules present in your connector project: the connectivity model (CCM), the Anypoint connector module (ACM), and the Flow connector module (FCM). Tests are split into data files and actual test files, creating a structured project. These tests include:
-
Tests for all use cases: This includes basic connectivity model, Anypoint Connector, and Flow Connector tests, pagination tests, and negative test cases.
-
Mock server for negative test cases: A mock server is used for negative test cases because replicating them against a live server is not always feasible.
-
Reusable test data: Test data is stored in separate files for easy reuse.
-
Self-contained tests for connector operations: These tests function independently. For example, if a connector has
POST,GET,PATCH, andDELETEoperations for/invoices, a self-contained test case can be generated, and the report reflects this.
Here’s an example of a generated test file for /calendars/{calendarId}/acl/{ruleId} - PATCH in a Google Calendar connector, which demonstrates the generation of parent operations, rule creation, and resource deletion:
If any operation is missing, a self-sustained test case can’t be generated, and the report indicates this. Here’s an example of a report for Google Calendar connector operations, which illustrates the status (SUCCESS and PARTIAL_SUCCESS) and messages indicating missing operations or complete test generation. This report is generated with the generated tests:
OPERATION NAME STATUS MESSAGE ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- calendar.calendars.delete SUCCESS Complete test generated calendar.calendarList.patch SUCCESS Complete test generated calendar.calendarList.insert PARTIAL_SUCCESS Missing DELETE operation - Self sustained testcase not generated - Resource DELETION needed calendar.calendarList.list PARTIAL_SUCCESS Missing DELETE operation - Self sustained testcase not generated - Resource DELETION needed calendar.events.get SUCCESS Complete test generated calendar.calendarList.update SUCCESS Complete test generated calendar.events.list SUCCESS Complete test generated calendar.colors.get PARTIAL_SUCCESS Missing CREATE and DELETE operation - Self sustained testcase not generated - Both Resource CREATION and DELETION needed calendar.acl.update SUCCESS Complete test generated calendar.calendarList.get SUCCESS Complete test generated calendar.acl.list SUCCESS Complete test generated calendar.calendars.update SUCCESS Complete test generated calendar.calendarList.delete SUCCESS Complete test generated calendar.events.move SUCCESS Complete test generated calendar.events.insert SUCCESS Complete test generated calendar.freebusy.query PARTIAL_SUCCESS Missing DELETE operation - Self sustained testcase not generated - Resource DELETION needed calendar.calendarList.watch PARTIAL_SUCCESS Missing DELETE operation - Self sustained testcase not generated - Resource DELETION needed calendar.acl.delete SUCCESS Complete test generated calendar.calendars.clear SUCCESS Complete test generated calendar.events.watch SUCCESS Complete test generated calendar.settings.watch PARTIAL_SUCCESS Missing DELETE operation - Self sustained testcase not generated - Resource DELETION needed calendar.events.patch SUCCESS Complete test generated calendar.settings.get PARTIAL_SUCCESS Missing CREATE and DELETE operation - Self sustained testcase not generated - Both Resource CREATION and DELETION needed calendar.acl.watch SUCCESS Complete test generated calendar.calendars.patch SUCCESS Complete test generated calendar.calendars.get SUCCESS Complete test generated calendar.calendars.insert PARTIAL_SUCCESS Missing DELETE operation - Self sustained testcase not generated - Resource DELETION needed calendar.channels.stop PARTIAL_SUCCESS Missing DELETE operation - Self sustained testcase not generated - Resource DELETION needed calendar.settings.list PARTIAL_SUCCESS Missing CREATE and DELETE operation - Self sustained testcase not generated - Both Resource CREATION and DELETION needed calendar.acl.patch SUCCESS Complete test generated calendar.events.delete SUCCESS Complete test generated calendar.events.update SUCCESS Complete test generated calendar.acl.get SUCCESS Complete test generated calendar.acl.insert SUCCESS Complete test generated calendar.events.quickAdd SUCCESS Complete test generated calendar.events.import SUCCESS Complete test generated calendar.events.instances SUCCESS Complete test generated
Generate Tests Without AI Assistance
If you generate tests without AI assistance, the test data will have placeholder data.
-
Open your IDE and go to Connector Builder - Editor.
-
If you haven’t generated your connector yet, click Generate > Generate Anypoint Connector or Generate > Generate Flow Connector.
-
Click Generate > Generate Tests. The available modules appear, with a dropdown for each. CCM is always available. ACM appears when an Anypoint connector module exists, and FCM appears when a Flow connector module exists.
-
For each available module, select the connection type. You can:
-
Use a real connection to the API (requires a connection profile). See Use Connection Profiles.
-
Use a mocked connection (no authentication required).
-
Skip test generation for that module.
-
-
Click Generate Tests. Tests are generated for each module according to the configuration you selected.
Generate Tests With AI Assistance (Cursor)
If you generate tests with AI assistance, AI helps generate test data.
-
Ensure Enable Ai Assisted Workflows is enabled.
-
Open your IDE and go to Connector Builder - Editor.
-
If you haven’t generated your connector yet, click Generate > Generate Anypoint Connector or Generate > Generate Flow Connector.
-
Click Generate > Generate Tests. The available modules appear, with a dropdown for each. CCM is always available. ACM appears when an Anypoint connector module exists, and FCM appears when a Flow connector module exists.
-
For each available module, select the connection type. You can:
-
Use a real connection to the API (requires a connection profile). See Use Connection Profiles.
-
Use a mocked connection (no authentication required).
-
Skip test generation for that module.
-
-
In Developer Documentation URL, enter the URL that will be used as the source for the AI test data generation.
-
Click Help me with test data generation. This copies a prepared prompt to your clipboard, which you can manually paste into the Cursor chat window.
-
Open the Cursor chat window (if not already open) and paste the copied prompt. Ensure you’re in Agent mode.
The agent analyzes the provided resources, and generates semantically accurate data for existing tests.
Generate Tests With MCP Tools (Cursor)
-
Open the Connector Builder extension in Cursor.
-
Select Settings and ensure Enable Mcp Tools is enabled.
-
Open the Cursor chat window (if not already open).
-
Ask the agent to check what tests can be generated. For example, enter
What can I generate tests for here?. This calls theuc_get_test_generation_infoMCP tool, which returns the available modules (CCM, ACM, FCM) and reports whether tests already exist. -
If existing tests are reported, confirm whether to overwrite them. Existing test files are deleted when overwrite is confirmed.
-
For each module you want to test, tell the agent whether to use a mocked connection or a real connection. For real connections, you need a connection profile ID, so use the
uc_list_connection_profilesMCP tool first to list connection profiles to retrieve the ID. -
Confirm your inputs. This calls the
uc_generate_testsMCP tool, which generates tests for the selected modules.
For more information, see MuleSoft DX MCP Server Tool Reference.
Run Tests
You can run tests without or with AI assistance (available when using Cursor). If you use AI assistance, you can make your generated test data semantically accurate. If you don’t use AI assistance, the data is only schematically accurate and requires manual effort.
Run Tests Without AI Assistance
-
Manually edit data files to provide relevant data for test cases.
-
To resolve failed tests, log the response to debug issues, for example:
var V_calendars__calendarId__acl_get_response = log(O_calendars__calendarId__acl_get.executor(V_calendars__calendarId__acl_get_request(CALENDARID), connection))
-
Run tests by using the
mvn testcommand.
Run Tests With AI Assistance (Cursor)
-
Ensure Enable Ai Assisted Workflows is enabled.
-
A rule file is generated to assist you in creating test data, at
<project root>/.cursor/rules/test-data-generation-rules. -
Open the Cursor chat window and ask the agent to create sample test data according to the generated rule file, referring to SaaS documentation as needed.
-
To resolve failed tests, log the response to debug issues, for example:
var V_calendars__calendarId__acl_get_response = log(O_calendars__calendarId__acl_get.executor(V_calendars__calendarId__acl_get_request(CALENDARID), connection))
-
Run tests by using the
mvn testcommand.
Validate the Connector
Before you release your connector, you can install the connector in the platform to make sure it works as expected.
Validate the Connector in Anypoint Platform
To validate the connector in Anypoint Platform, you can install the connector in Anypoint Studio or Anypoint Code Builder.
-
In the
pom.xmlfile, ensuremule-maven-plugin-versionis 4.6.0 or later. -
In the
pom.xmlfile, add your connector dependency, for example:<dependencies> <dependency> <groupId>com.mulesoft.connectivity.flights</groupId> <artifactId>flights-anypoint-connector-model</artifactId> <version>0.0.3-SNAPSHOT</version> <classifier>mule-plugin</classifier> </dependency> </dependencies>
Now, your connector appears in Anypoint Studio or Anypoint Code Builder and you can test the connector functionality.



