---
schema_version: "1"
id: dbe55c4f7a5f21752ccfc7549b3fe2329a56e6b1b4e0cb5de479847faa3d1039
title: Archive Apex Testing
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/archive_apex_testing.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.archive_apex_testing.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 15108adfbceba0adc17a18f2cb96312eff8fa34708cdbdff3e1c63d789a394cd
description: Before working in your production environment, test your Apex Class Wrapper in Archive Apex in the Archive app.
products:
  - Salesforce Platform
  - Cross Cloud
release: "264"
---
# Archive Apex Testing

Before working in your production environment, test your Apex Class Wrapper in Archive Apex in the Archive app.

## MockHttpResponseGenerator.cls

This code depicts the mock for the callout. The `MockHttpResponseGenerator` class implements the `HttpCalloutMock` Apex interface.

```
@isTest
global class MockHttpResponseGenerator implements HttpCalloutMock {
public String fakeResponseJson;
public integer statusCode;
String redirectHeader;

public MockHttpResponseGenerator(String fakeResponseJson,Integer statusCode){
this.statusCode = statusCode;
this.fakeResponseJson = fakeResponseJson;
this.redirectHeader = '/example/test';

}

public HTTPResponse respond(HTTPRequest req) {
HTTPResponse res = new HTTPResponse();
res.setBody(this.fakeResponseJson);
res.setStatusCode(this.statusCode);
res.setHeader('Location',  this.redirectHeader);
return res;
}
}
```

## SearchSdkTest.cls

This code tests the global search functionality of the `SF_Archive.ArchiverAccessor` by setting up a mock HTTP response using the `MockHttpResponseGenerator` class. This test verifies that the search operation returns the expected JSON data and status code.

```
@isTest
public with sharing class SearchSdkTest {
    @isTest
    private static void searchSdk() {
        String jsonBody = '{"records":[{"CaseNumber":"01916767","Id":"500Xx000000XXXXXX"}],"total_result_count":1,"scroll_id":"-1"}';

        SF_Archive.ArchiverAccessor.setMock(new MockHttpResponseGenerator(
            jsonBody, SF_Archive.ArchiverAccessorResponse.HTTP_200_OK));

        List<SF_Archive.SearchFilter> filters = new List<SF_Archive.SearchFilter>{
            new SF_Archive.SearchFilter('Name', 'test')
        };

        Test.startTest();
        SF_Archive.ArchiverAccessorResponse res =
            SF_Archive.ArchiverAccessor.performArchiverGlobalSearch('Account', filters);
        Test.stopTest();

        System.assertEquals(SF_Archive.ArchiverAccessorResponse.HTTP_200_OK, res.getStatusCode());
        System.assertEquals(jsonBody, res.getBody());
    }
}
```