# Testing Tutorial
source: https://developer.mastercard.com/easy-savings-specials/documentation/tutorial-and-guide/testing/index.md

## Overview {#overview}

This section outlines use cases that can be tested using the Sandbox environment for the Easy Savings Specials Merchant Offers API. The Sandbox environment includes limited-capacity mock APIs, allowing you to try out the APIs and assist with initial integration and solution development. It returns mock responses based on defined requests. Specific values in the request body, such as path parameters or fields, trigger predefined responses.

## Easy Savings Specials Merchant Offers API test cases {#easy-savings-specials-merchant-offers-api-test-cases}

### Offers {#offers}

#### Validate response for Offers API {#validate-response-for-offers-api}

You can query and filter a list of offers by country, language, offset, and limit. To apply filters, set the country, language, offset, and limit fields. The default limit is 30, and the default offset is 0. The minimum required parameters for a successful response are BIN, country, and language.
* URL

```URL
https://sandbox.sme.api.mastercard.com/easysavings/specials/offers?bin=52345678&country=IND&language=en-US&offset=10&limit=5
```

```java
{
  "entity": "collection",
  "offset": 0,
  "limit": 30,
  "count": 30,
  "total": 30,
  "offers": [
    {
      "offerId": "QDWC0NRZmyabde",
      "type": "offer",
      "status": "active",
      "startDate": "2023-12-21",
      "endDate": "2024-09-14",
      "displayParameters": {
        "name": "Amazon Special Offer",
        "description": "Get 10% off on your purchase",
        "terms": "Minimum purchase of 1000 rupees required",
        "redemptionChannels": [
          "online"
        ],
        "redemptionUrl": "https://www.test.com/redeem",
        "imageUrl": "https://www.test.com/"
      },
      "merchant": {
        "name": "Amazon",
        "website": "https://www.amazon.com/",
        "description": "Online shopping platform",
        "logoUrl": "https://merchant.com/"
      },
      "categories": [
        "shopping"
      ]
    }
  ]
}
```

#### Negative test cases {#negative-test-cases}

##### Test Case 1: BIN is invalid {#test-case-1-bin-is-invalid}

In this test scenario, no BIN parameter was passed, resulting in an exception. To resolve this, verify and retry with the correct BIN parameter value.
* URL

```URL
https://sandbox.sme.api.mastercard.com/easysavings/specials/offers?bin=5234567&country=IND&language=en-US&limit=30&offset=0
```

```java
{
    "Errors": {
        "Error": [
            {
                "Source": "EasySavingsSpecialsOffers",
                "ReasonCode": "INVALID_BIN",
                "Description": "The BIN provided does not conform to the expected Mastercard format.",
                "Recoverable": false,
                "Details": "An invalid 8-digit Mastercard Business BIN has been provided."
            }
        ]
    }
}
```

##### Test Case 2: Country details are missing {#test-case-2-country-details-are-missing}

In this test scenario, no country parameter was passed, resulting in an exception. To resolve this, verify and retry with the correct country parameter value.
* URL

```URL
https://sandbox.sme.api.mastercard.com/easysavings/specials/offers?bin=52345678&language=en-US
```

```java
{
    "Errors": {
        "Error": [
            {
                "Source": "EasySavingsSpecialsOffers",
                "ReasonCode": "NULL_COUNTRY",
                "Description": "Country parameter must not be null or empty",
                "Recoverable": false,
                "Details": "Country code should be a three-lettered ISO code"
            }
        ]
    }
}
```

##### Test Case 3: Language details are missing {#test-case-3-language-details-are-missing}

In this test scenario, no language parameter was passed, resulting in an exception. To resolve this, verify and retry with the correct language parameter value.
* URL

```URL
https://sandbox.sme.api.mastercard.com/easysavings/specials/offers?bin=52345678&country=IND&limit=30&offset=0
```

```java
{
    "Errors": {
        "Error": [
            {
                "Source": "EasySavingsSpecialsOffers",
                "ReasonCode": "NULL_LANGUAGE",
                "Description": "Language parameter must not be null or empty",
                "Recoverable": false,
                "Details": "Language code should match the IETF BCP format"
            }
        ]
    }
}
```

### Redemptions {#redemptions}

#### Validate response for POST Redemptions API {#validate-response-for-post-redemptions-api}

* URL

```URL
https://sandbox.sme.api.mastercard.com/easysavings/specials/redemptions
```

##### Request Parameters {#request-parameters}

```java
{
  "bin": "52345678",
  "offers": [
    {
      "id": "QDWC0NRZmyabde"
    }
  ]
}
```

```java
{
  "orderId": "QITxGqu30qzxcv",
  "entity": "orders",
  "status": "success",
  "createdAt": "2022-12-20",
  "orders": {
    "count": 1,
    "orderItems": [
      {
        "offerId": "QDWC0NRZmyabde",
        "status": "success",
        "vouchers": [
          {
            "code": "test"
          }
        ]
      }
    ]
  }
}
```

#### Negative test cases {#negative-test-cases-1}

##### Test Case 1: BIN and offerId request parameters are missing {#test-case-1-bin-and-offerid-request-parameters-are-missing}

In this test scenario, an empty request body was passed, resulting in an exception. To resolve this, verify and retry with the correct request body parameters.
* URL

```URL
https://sandbox.sme.api.mastercard.com/easysavings/specials/redemptions
```

```java
{
    "Errors": {
        "Error": [
            {
                "Source": "EasySavingsSpecialsOffers",
                "ReasonCode": "NULL_BIN",
                "Description": "BIN parameter must not be null or empty",
                "Recoverable": false,
                "Details": "BIN parameter is not passed correctly"
            },
            {
                "Source": "EasySavingsSpecialsOffers",
                "ReasonCode": "NULL_OFFER_ID",
                "Description": "Offer_ID parameter must not be null or empty",
                "Recoverable": false,
                "Details": "Offer_ID is the unique identifier of the offer"
            }
        ]
    }
}
```

##### Test Case 2: The BIN parameter is missing {#test-case-2-the-bin-parameter-is-missing}

In this test scenario, no BIN was passed in the request body, resulting in an exception. To resolve this, verify and retry with the correct BIN value.
* URL

```URL
https://sandbox.sme.api.mastercard.com/easysavings/specials/redemptions
```

```java
{
    "Errors": {
        "Error": [
            {
                "Source": "EasySavingsSpecialsOffers",
                "ReasonCode": "NULL_BIN",
                "Description": "BIN parameter must not be null or empty",
                "Recoverable": false,
                "Details": "BIN parameter is not passed correctly"
            }
        ]
    }
}
```

#### Validate response for GET Redemptions API {#validate-response-for-get-redemptions-api}

* URL

```URL
https://sandbox.sme.api.mastercard.com/easysavings/specials/redemptions/QDWC0NRZmyabde
```

```java
{
  "orderId": "QITxGqu30qzxcv",
  "entity": "orders",
  "status": "success",
  "createdAt": "2022-12-20",
  "orders": {
    "count": 1,
    "orderItems": [
      {
        "offerId": "QDWC0NRZmyabde",
        "status": "success",
        "vouchers": [
          {
            "code": "test"
          }
        ]
      }
    ]
  }
}
```

#### Negative test cases {#negative-test-cases-2}

##### Test Case 1: An incorrect order_id was provided {#test-case-1-an-incorrect-order_id-was-provided}

In this test scenario, a valid order ID was not passed, resulting in an exception. To resolve this, verify and retry with the correct order ID.
* URL

```URL
https://sandbox.sme.api.mastercard.com/easysavings/specials/redemptions/QDWC0NRZmyabe
```

```java
{
    "Errors": {
        "Error": [
            {
                "Source": "EasySavingsSpecialsOffers",
                "ReasonCode": "ORDER_ID_NOT_FOUND",
                "Description": "The Order_ID parameter is either incorrect or has expired.",
                "Recoverable": false,
                "Details": "The Order_ID parameter is the unique identifier of the previously generated order."
            }
        ]
    }
}
```

### Countries {#countries}

#### Validate response for GET Countries API {#validate-response-for-get-countries-api}

* URL

```URL
https://sandbox.sme.api.mastercard.com/easysavings/specials/countries
```

```java
{
  "countries": [
    {
      "isoCode": "EGY",
      "languages": [
        {
          "languageCode": "ar-SA"
        }
      ]
    }
  ]
}
```

