Salesforce-to-Xero Integration — Business Rules Engine with Automated Testing
XeroHttpMock.cls — reusable HttpCalloutMock implementation covering all Xero API endpoints, with canned JSON responsesXeroApiServiceTest, XeroContactServiceTest, XeroInvoiceServiceTestXeroCreditNoteServiceTest, XeroJournalServiceTestXeroWebhookHandlerTest, XeroWebhookProcessorTest, XeroWebhookEventHandlerTestXeroTokenRefreshJobTest, XeroTokenRefreshSchedulerTest, XeroApiLoggerTestxeroIntegrationTest component with mocked @wire and imperative Apex callssf apex run test passes in sandbox — 87 tests, 100% pass rateBilling_Schedule__c, Contracted_Asset_Start_Date__c, etc.)proposed_change notes)python3 scripts/yaml-to-cmt.py), rebuild viewer (python3 scripts/build-rules-viewer.py), deploy to sandboxBusiness_Rule__mdt at runtime and evaluates rules against records.BusinessRuleEngine.cls — the core evaluator
Business_Rule__mdt records filtered by object name and eventConditions_JSON__c and evaluates against SObject using dynamic field accessall (AND) / any (OR)List<RuleEvaluationResult> with rule ID, action, messageList<Business_Rule__mdt> parameter for testabilityIRuleActionHandler interfaceBlockSyncHandler, FlagRecordHandler, AlertHandler, MapFieldHandler, ExecuteApexHandler, LogHandler, RequireApprovalHandlerRuleActionFactory to instantiate handler by action nameBusinessRuleEngineTest.cls, RuleActionFactoryTest.cls — using in-memory CMT recordsTestDataFactory.cls — shared test data builder with methods like createOpportunity(stage, tcv, currency)scripts/generate-test-specs.py — reads YAML, outputs Gherkin scenarios for each approved rule. This is the CFO sign-off document.BusinessRuleBDDTest.cls — one @IsTest method per approved rule, using GIVEN/WHEN/THEN commentsXeroIntegrationBDDTest.cls — integration-level tests calling @AuraEnabled service methods through the rules engineXero_API) and OAuth token refresh. Confirm XeroTokenRefreshScheduler is running.sf apex run test --test-level RunAllTests. Target: 85%+ coverage, all tests green.xeroIntegrationTest LWC — verify rules are blocking/allowing syncs as expectedafterEach hooks — delete test records from both SF and XeroIs_Active__c = true where CFO_Decision__c != 'Accepted'Xero_Integration_Settings__c values prepared