Skip to content

The MockDuplicates.DuplicateResult Class

GitHub Action edited this page Nov 11, 2025 · 1 revision

Represents a duplicate rule result with match results and save behavior in test scenarios.

This class extends Duplicates.DuplicateResult and provides a fluent API for building duplicate detection results for a specific rule.

Methods

addMatch

Adds a match result for a specific record. Returns the created MatchResult instance for method chaining.

  • MockDuplicates.MatchResult addMatch()
MockDuplicates.MatchResult match = dupResult.addMatch();

clearMatches

Removes all match results from this duplicate rule result. Returns this instance for method chaining.

  • MockDuplicates.DuplicateResult clearMatches()
dupResult.clearMatches();

setErrorMessage

Sets the error message for this duplicate rule result. Returns this instance for method chaining.

  • MockDuplicates.DuplicateResult setErrorMessage(String errorMessage)
dupResult.setErrorMessage('Custom duplicate alert message');

setRuleName

Sets the duplicate rule name. Returns this instance for method chaining.

  • MockDuplicates.DuplicateResult setRuleName(String ruleName)
dupResult.setRuleName('Account_Duplicate_Rule');

setSaveBehavior

Sets whether records can be saved despite duplicates. The behavior parameter can be either MockDuplicates.SaveBehavior.ALLOW or MockDuplicates.SaveBehavior.BLOCK. Returns this instance for method chaining.

  • MockDuplicates.DuplicateResult setSaveBehavior(MockDuplicates.SaveBehavior behavior)
dupResult.setSaveBehavior(MockDuplicates.SaveBehavior.BLOCK);

toTop

Navigates back to the top-level FindDuplicatesResult.

  • MockDuplicates.FindDuplicatesResult toTop()
MockDuplicates.FindDuplicatesResult result = dupResult.toTop();

up

Navigates back to the parent FindDuplicatesResult.

  • MockDuplicates.FindDuplicatesResult up()
MockDuplicates.FindDuplicatesResult result = dupResult.up();

apex-database-layer

Home

Core Concepts

Reference Guide

Migration Gudes

Clone this wiki locally