package com.razorpay;

import org.junit.Test;
import org.mockito.InjectMocks;

import java.io.IOException;
import java.util.List;

import static org.junit.Assert.*;

public class CardClientTest extends BaseTest{

    @InjectMocks
    protected CardClient cardClientClient = new CardClient(TEST_SECRET_KEY);

    private static final String CARD_ID = "card_DZon6fd8J3IcA2";

    @Test
    public void fetch() throws RazorpayException {

        String json = "{\n  \"id\": \"card_DZon6fd8J3IcA2\",\n  \"entity\": \"card\",\n  \"international\": false,\n  \"last4\": 1111,\n  \"name\": \"sample name\",\n  \"network\": \"Visa\",\n  \"type\": \"debit\"\n}";
        try {
            mockResponseFromExternalClient(json);
            mockResponseHTTPCodeFromExternalClient(200);
            Card fetch = cardClientClient.fetch(CARD_ID);
            assertNotNull(fetch);
            assertEquals(CARD_ID,fetch.get("id"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
@@ -444,17 +444,31 @@
  String 
-j
+mockedResponseJ
 son = %22%7B
@@ -483,30 +483,18 @@
 %5C%22: 
-%5C%22card_DZon6fd8J3IcA2%5C
+%22+CARD_ID+
 %22,%5Cn
@@ -707,17 +707,31 @@
 lClient(
-j
+mockedResponseJ
 son);%0A  

change json name to mockedResponseJson