---
schema_version: "1"
id: 763201b10b97c8e1d289de21fc31f94bed732ec287e676ff4b5d1f934bb1ae9c
title: RTRReportResult.MockRTRReportResult
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/retail_api/MockRTRReportResult_class.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/MockRTRReportResult_class.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 91452eeb0e9509f08dbc5f7209326248da00ef7c71603535d5fd8b76985f58bf
description: This class is used to create mock responses for the unit test execution.
---
# RTRReportResult.MockRTRReportResult

This class is used to create mock responses for the unit test execution.

The RTRReportResult.MockRTRReportResult class extends RTRReportResult.

The supported modifiers are global and virtual.

## Namespace

cgcloud

## Supported Methods

<table class="featureTable sort_table" summary="">
          <caption><span class="tablecap">Table 1. RTRReportResult.MockRTRReportResult Supported Methods</span></caption>



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d35563e86">Method signature</th>

              <th class="featureTableHeader  " id="d35563e89">Description</th>

              <th class="featureTableHeader  " id="d35563e92">Version</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d35563e86" data-title="Method signature"><samp class="codeph nolang">RTRReportResult.MockRTRReportResult​(Map&lt;String,
                  RTRReportResult.ReportComponent&gt;​ components)</samp></td>

              <td class="entry" headers="d35563e89" data-title="Description">The constructor for creating mock responses for the unit test execution.
                <p class="p"><span class="keyword parmname">components</span>: Map&lt;String, RTRReportResult.ReportComponent&gt;&nbsp;. A
                  map of a reporting component name to a mock report component instance.</p>

                <p class="p">The mocked value is returned when the <samp class="codeph nolang">getComponent</samp>
                  method is executed.</p>
              </td>

              <td class="entry" headers="d35563e92" data-title="Version">60.0</td>

            </tr>

          </tbody>

        </table>

## Example Implementation

@IsTest
  public static void myTestMethod() {
    // Setup

    // Setup your required data for the test

    // Expected RTR Report Filters
    Map<String, Object> expectedReportFilters = null; //...

    // Create a mock RTRReportResult
    cgcloud.RTRReportResult.MockRTRReportResult mockReportResult = new cgcloud.RTRReportResult.MockRTRReportResult(
      // Create a map with the returned report components
      new Map<String, cgcloud.RTRReportResult.ReportComponent>{
        // Flatlist component
        'FlatList' => new cgcloud.RTRReportResult.MockFlatlist(
          // For a flatlist, specify the mocked rows
          new List<cgcloud.RTRReportResult.MockFlatlistRow>{
            new cgcloud.RTRReportResult.MockFlatlistRow(
              // For each row, set the column values
              new Map<String, Object>{
                'RowType' => 'Product-Promo', // RowType is required
                'productdimension.id' => productid1,
                'KPI1' => 123,
                'KPI2' => 456
              }
            ),
            new cgcloud.RTRReportResult.MockFlatlistRow(
              // For each row, set the column values
              new Map<String, Object>{
                'RowType' => 'Product-Promo', // RowType is required
                'productdimension.id' => productid2,
                'KPI1' => 789,
                'KPI2' => 123
              }
            )
          }
        )
      }
    );

    // Set the mock in RTRReportResult.execute so the call to this method
    // returns our mock response
    cgcloud.RTRReportResult.setMock(new List<Object>{ mockReportResult });

    // Test

    // Run your code to be tested. RTRReportResult.execute call will
    // return the mock result

    // Assert

    // Assert your code is working as expected.

    // You can also validate RTRReportResult.execute was called with the expected
    // parameters
    system.assertEquals('0001', mockReportResult.getSalesOrg());
    system.assertEquals('MySampleReport', mockReportResult.getReportName());
    system.assertEquals(expectedReportFilters, mockReportResult.getFilters());
  }