// Path: src/test/java/com/cardinity/CardinityBaseTest.java
// public abstract class CardinityBaseTest {
// 
//     protected final static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
//     protected final static SimpleDateFormat formatterWithMillis = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
//     protected final static SimpleDateFormat formatterWithMillisEET = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
// 
//     static {
//         formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
//         formatterWithMillis.setTimeZone(TimeZone.getTimeZone("UTC"));
//         formatterWithMillisEET.setTimeZone(TimeZone.getTimeZone("EET"));
//     }
// 
//     protected String resource(String path) throws IOException {
// 
//         InputStream resource = getClass().getResourceAsStream(path);
// 
//         ByteArrayOutputStream os = new ByteArrayOutputStream(1024);
//         byte[] buf = new byte[1024];
// 
//         for (int i = resource.read(buf); i > 0; i = resource.read(buf)) {
//             os.write(buf, 0, i);
//         }
// 
//         return os.toString(Cardinity.ENCODING_CHARSET);
// 
//     }
// }
// 
// Path: src/main/java/com/cardinity/exceptions/CardinityException.java
// public abstract class CardinityException extends RuntimeException {
// 
//     private static final long serialVersionUID = -4551051157520060255L;
// 
//     public CardinityException(String message) {
//         super(message, null);
//     }
// 
// }
// 
// Path: src/main/java/com/cardinity/rest/RestResource.java
// public abstract class RestResource {
// 
//     // @formatter:off
//     public static final Gson GSON = new GsonBuilder()
//             .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
//             .registerTypeAdapter(Payment.class, new PaymentDeserializer())
//             .registerTypeAdapter(Card.class, new CardSerializer())
//             .registerTypeAdapter(Date.class, new UtcDateTypeAdapter())
//             .create();
//     // @formatter:on
// 
// 
//     public enum RequestMethod {
//         GET, PATCH, POST
//     }
// 
//     public enum Resource {
//         PAYMENTS, REFUNDS, SETTLEMENTS, VOIDS, CHARGEBACKS
//     }
// 
// }


import com.cardinity.CardinityBaseTest;
import com.cardinity.exceptions.CardinityException;
import com.cardinity.rest.RestResource;
import org.junit.Test;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.UUID;
import static org.junit.Assert.*;
        String json = resource("pending_payment_v2.json");
        Payment payment = RestResource.GSON.fromJson(json, Payment.class);

        assertEquals(UUID.fromString("8e037fbb-fe5b-4781-b109-b3e93d5f2c0d"), payment.getId());
        assertEquals("EUR", payment.getCurrency());
        assertEquals(new BigDecimal("20.00"), payment.getAmount());
        assertEquals(formatterWithMillis.parse("2014-12-17T09:43:31.123Z"), payment.getCreated());
        assertFalse(payment.getLive());
        assertEquals(Payment.Type.AUTHORIZATION, payment.getType());
        assertEquals(Payment.Status.PENDING, payment.getStatus());
        assertEquals("1234567", payment.getOrderId());
        assertEquals("some description", payment.getDescription());
        assertEquals("LT", payment.getCountry());
        assertEquals(Payment.Method.CARD, payment.getPaymentMethod());
        assertNotNull(payment.getPaymentInstrument());
        assertEquals(Payment.Method.CARD, payment.getPaymentInstrument().getType());

        Card card = (Card) payment.getPaymentInstrument();
        assertEquals("4447", card.getPan());
        assertEquals("John Smith", card.getHolder());
        assertEquals("Visa", card.getCardBrand());
        assertEquals(Integer.valueOf(2017), card.getExpYear());
        assertEquals(Integer.valueOf(5), card.getExpMonth());

        assertNull(payment.getAuthorizationInformation());
        assertNotNull(payment.getThreeds2AuthorizationInformation());
        assertEquals("https://authorization.url/3ds2/auth", payment.getThreeds2AuthorizationInformation().getAcsUrl());
        assertEquals("34uifnui3n4fio3fo3", payment.getThreeds2AuthorizationInformation().getCReq());
    }

// Path: src/test/java/com/cardinity/CardinityBaseTest.java
// public abstract class CardinityBaseTest {
// 
//     protected final static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
//     protected final static SimpleDateFormat formatterWithMillis = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
//     protected final static SimpleDateFormat formatterWithMillisEET = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
// 
//     static {
//         formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
//         formatterWithMillis.setTimeZone(TimeZone.getTimeZone("UTC"));
//         formatterWithMillisEET.setTimeZone(TimeZone.getTimeZone("EET"));
//     }
// 
//     protected String resource(String path) throws IOException {
// 
//         InputStream resource = getClass().getResourceAsStream(path);
// 
//         ByteArrayOutputStream os = new ByteArrayOutputStream(1024);
//         byte[] buf = new byte[1024];
// 
//         for (int i = resource.read(buf); i > 0; i = resource.read(buf)) {
//             os.write(buf, 0, i);
//         }
// 
//         return os.toString(Cardinity.ENCODING_CHARSET);
// 
//     }
// }
// 
// Path: src/main/java/com/cardinity/exceptions/CardinityException.java
// public abstract class CardinityException extends RuntimeException {
// 
//     private static final long serialVersionUID = -4551051157520060255L;
// 
//     public CardinityException(String message) {
//         super(message, null);
//     }
// 
// }
// 
// Path: src/main/java/com/cardinity/rest/RestResource.java
// public abstract class RestResource {
// 
//     // @formatter:off
//     public static final Gson GSON = new GsonBuilder()
//             .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
//             .registerTypeAdapter(Payment.class, new PaymentDeserializer())
//             .registerTypeAdapter(Card.class, new CardSerializer())
//             .registerTypeAdapter(Date.class, new UtcDateTypeAdapter())
//             .create();
//     // @formatter:on
// 
// 
//     public enum RequestMethod {
//         GET, PATCH, POST
//     }
// 
//     public enum Resource {
//         PAYMENTS, REFUNDS, SETTLEMENTS, VOIDS, CHARGEBACKS
//     }
// 
// }


// Path: src/test/java/com/cardinity/model/DeserializationTest.java
import com.cardinity.CardinityBaseTest;
import com.cardinity.exceptions.CardinityException;
import com.cardinity.rest.RestResource;
import org.junit.Test;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.UUID;
import static org.junit.Assert.*;

        String json = resource("pending_payment_v2.json");
        Payment payment = RestResource.GSON.fromJson(json, Payment.class);

        assertEquals(UUID.fromString("8e037fbb-fe5b-4781-b109-b3e93d5f2c0d"), payment.getId());
        assertEquals("EUR", payment.getCurrency());
        assertEquals(new BigDecimal("20.00"), payment.getAmount());
        assertEquals(formatterWithMillis.parse("2014-12-17T09:43:31.123Z"), payment.getCreated());
        assertFalse(payment.getLive());
        assertEquals(Payment.Type.AUTHORIZATION, payment.getType());
        assertEquals(Payment.Status.PENDING, payment.getStatus());
        assertEquals("1234567", payment.getOrderId());
        assertEquals("some description", payment.getDescription());
        assertEquals("LT", payment.getCountry());
        assertEquals(Payment.Method.CARD, payment.getPaymentMethod());
        assertNotNull(payment.getPaymentInstrument());
        assertEquals(Payment.Method.CARD, payment.getPaymentInstrument().getType());

        Card card = (Card) payment.getPaymentInstrument();
        assertEquals("4447", card.getPan());
        assertEquals("John Smith", card.getHolder());
        assertEquals("Visa", card.getCardBrand());
        assertEquals(Integer.valueOf(2017), card.getExpYear());
        assertEquals(Integer.valueOf(5), card.getExpMonth());

        assertNull(payment.getAuthorizationInformation());
        assertNotNull(payment.getThreeds2AuthorizationInformation());
        assertEquals("https://authorization.url/3ds2/auth", payment.getThreeds2AuthorizationInformation().getAcsUrl());
        assertEquals("34uifnui3n4fio3fo3", payment.getThreeds2AuthorizationInformation().getCReq());
    }

    @Test(expected = CardinityException.class)