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

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

The RTRReportResult.MockFlatlist class extends RTRReportResult.Flatlist.

The supported modifiers are global and virtual.

## Namespace

cgcloud

## Supported Methods

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



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

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

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

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d35298e86" data-title="Method signature">RTRReportResult.MockFlatlist​(List&lt;RTRReportResult.MockFlatlistRow&gt;
                rows)</td>

              <td class="entry" headers="d35298e89" data-title="Description">The constructor for creating mock responses for the unit test execution.
                <p class="p"><span class="keyword parmname">rows</span>: List&lt;RTRReportResult.MockFlatlistRow&gt;&nbsp;. The list of
                  <samp class="codeph nolang">MockFlatlistRow</samp> instances contained in <samp class="codeph nolang">MockFlatlist</samp>.
                </p>

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

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

            </tr>

          </tbody>

        </table>

## Example Implementation

To unit test a Flatlist component in, mock the resulting report data rows with the MockFlatlist and MockFlatlistRow classes.

@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());
  }