// Path: src/test/java/com/yelp/clientlib/utils/JsonTestUtils.java
// public class JsonTestUtils {
//     public static final String BUSINESS_RESPONSE_JSON_FILENAME = "businessResponse.json";
// 
//     public static final String SEARCH_RESPONSE_JSON_FILENAME = "searchResponse.json";
// 
//     public static JsonNode getBusinessResponseJsonNode() throws IOException {
//         return getJsonNodeFromFile(BUSINESS_RESPONSE_JSON_FILENAME);
//     }
// 
//     public static JsonNode getSearchResponseJsonNode() throws IOException {
//         return getJsonNodeFromFile(SEARCH_RESPONSE_JSON_FILENAME);
//     }
// 
//     public static JsonNode getJsonNodeFromFile(String filename) throws IOException {
//         File jsonFile = new File(JsonTestUtils.class.getClassLoader().getResource(filename).getFile());
//         return new ObjectMapper().readTree(jsonFile);
//     }
// 
//     public static <T> T deserializeJson(String content, Class<T> valueType) throws IOException {
//         return new ObjectMapper().readValue(content, valueType);
//     }
// }
// 
// Path: src/test/java/com/yelp/clientlib/utils/SerializationTestUtils.java
// public class SerializationTestUtils {
// 
//     /**
//      * Serialize an object into a byte array. The object has to implement {@link Serializable} interface.
//      *
//      * @param object Object to be serialized.
//      * @return Byte array serialized from the object.
//      */
//     public static <T extends Serializable> byte[] serialize(T object) throws IOException {
//         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
//         ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
//         objectOutputStream.writeObject(object);
//         objectOutputStream.close();
// 
//         return byteArrayOutputStream.toByteArray();
//     }
// 
//     /**
//      * Deserialize a byte array into an object. The object has to implement {@link Serializable} interface.
//      *
//      * @param bytes Byte array to be deserialized.
//      * @param clazz Class type the object should be deserialized into.
//      * @return Object deserialized from the byte array.
//      */
//     public static <T extends Serializable> T deserialize(byte[] bytes, Class<T> clazz)
//             throws IOException, ClassNotFoundException {
//         ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
//         ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
//         Object object = objectInputStream.readObject();
// 
//         return clazz.cast(object);
//     }
// }


import com.fasterxml.jackson.databind.JsonNode;
import com.yelp.clientlib.utils.JsonTestUtils;
import com.yelp.clientlib.utils.SerializationTestUtils;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
package com.yelp.clientlib.entities;




public class DealOptionTest {

    @Test
    public void testDeserializeFromJson() throws IOException {
        JsonNode dealOptionNode = JsonTestUtils.getBusinessResponseJsonNode()
                .path("deals").get(0).path("options").get(0);
        DealOption dealOption = JsonTestUtils.deserializeJson(dealOptionNode.toString(), DealOption.class);

        Assert.assertEquals(
                dealOptionNode.path("formatted_original_price").textValue(),
                dealOption.formattedOriginalPrice()
        );
        Assert.assertEquals(dealOptionNode.path("formatted_price").textValue(), dealOption.formattedPrice());
        Assert.assertEquals(dealOptionNode.path("is_quantity_limited").asBoolean(), dealOption.isQuantityLimited());
        Assert.assertEquals(new Integer(dealOptionNode.path("original_price").asInt()), dealOption.originalPrice());
        Assert.assertEquals(new Integer(dealOptionNode.path("price").asInt()), dealOption.price());
        Assert.assertEquals(dealOptionNode.path("purchase_url").textValue(), dealOption.purchaseUrl());
        Assert.assertEquals(new Integer(dealOptionNode.path("remaining_count").asInt()), dealOption.remainingCount());
        Assert.assertEquals(dealOptionNode.path("title").textValue(), dealOption.title());
    }

    @Test
    public void testSerializable() throws IOException, ClassNotFoundException {
        JsonNode dealOptionNode = JsonTestUtils.getBusinessResponseJsonNode()
                .path("deals").get(0).path("options").get(0);
        DealOption dealOption = JsonTestUtils.deserializeJson(dealOptionNode.toString(), DealOption.class);

        byte[] bytes = SerializationTestUtils.serialize(dealOption);
// Path: src/test/java/com/yelp/clientlib/utils/JsonTestUtils.java
// public class JsonTestUtils {
//     public static final String BUSINESS_RESPONSE_JSON_FILENAME = "businessResponse.json";
// 
//     public static final String SEARCH_RESPONSE_JSON_FILENAME = "searchResponse.json";
// 
//     public static JsonNode getBusinessResponseJsonNode() throws IOException {
//         return getJsonNodeFromFile(BUSINESS_RESPONSE_JSON_FILENAME);
//     }
// 
//     public static JsonNode getSearchResponseJsonNode() throws IOException {
//         return getJsonNodeFromFile(SEARCH_RESPONSE_JSON_FILENAME);
//     }
// 
//     public static JsonNode getJsonNodeFromFile(String filename) throws IOException {
//         File jsonFile = new File(JsonTestUtils.class.getClassLoader().getResource(filename).getFile());
//         return new ObjectMapper().readTree(jsonFile);
//     }
// 
//     public static <T> T deserializeJson(String content, Class<T> valueType) throws IOException {
//         return new ObjectMapper().readValue(content, valueType);
//     }
// }
// 
// Path: src/test/java/com/yelp/clientlib/utils/SerializationTestUtils.java
// public class SerializationTestUtils {
// 
//     /**
//      * Serialize an object into a byte array. The object has to implement {@link Serializable} interface.
//      *
//      * @param object Object to be serialized.
//      * @return Byte array serialized from the object.
//      */
//     public static <T extends Serializable> byte[] serialize(T object) throws IOException {
//         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
//         ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
//         objectOutputStream.writeObject(object);
//         objectOutputStream.close();
// 
//         return byteArrayOutputStream.toByteArray();
//     }
// 
//     /**
//      * Deserialize a byte array into an object. The object has to implement {@link Serializable} interface.
//      *
//      * @param bytes Byte array to be deserialized.
//      * @param clazz Class type the object should be deserialized into.
//      * @return Object deserialized from the byte array.
//      */
//     public static <T extends Serializable> T deserialize(byte[] bytes, Class<T> clazz)
//             throws IOException, ClassNotFoundException {
//         ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
//         ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
//         Object object = objectInputStream.readObject();
// 
//         return clazz.cast(object);
//     }
// }


// Path: src/test/java/com/yelp/clientlib/entities/DealOptionTest.java
import com.fasterxml.jackson.databind.JsonNode;
import com.yelp.clientlib.utils.JsonTestUtils;
import com.yelp.clientlib.utils.SerializationTestUtils;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;

package com.yelp.clientlib.entities;




public class DealOptionTest {

    @Test
    public void testDeserializeFromJson() throws IOException {
        JsonNode dealOptionNode = JsonTestUtils.getBusinessResponseJsonNode()
                .path("deals").get(0).path("options").get(0);
        DealOption dealOption = JsonTestUtils.deserializeJson(dealOptionNode.toString(), DealOption.class);

        Assert.assertEquals(
                dealOptionNode.path("formatted_original_price").textValue(),
                dealOption.formattedOriginalPrice()
        );
        Assert.assertEquals(dealOptionNode.path("formatted_price").textValue(), dealOption.formattedPrice());
        Assert.assertEquals(dealOptionNode.path("is_quantity_limited").asBoolean(), dealOption.isQuantityLimited());
        Assert.assertEquals(new Integer(dealOptionNode.path("original_price").asInt()), dealOption.originalPrice());
        Assert.assertEquals(new Integer(dealOptionNode.path("price").asInt()), dealOption.price());
        Assert.assertEquals(dealOptionNode.path("purchase_url").textValue(), dealOption.purchaseUrl());
        Assert.assertEquals(new Integer(dealOptionNode.path("remaining_count").asInt()), dealOption.remainingCount());
        Assert.assertEquals(dealOptionNode.path("title").textValue(), dealOption.title());
    }

    @Test
    public void testSerializable() throws IOException, ClassNotFoundException {
        JsonNode dealOptionNode = JsonTestUtils.getBusinessResponseJsonNode()
                .path("deals").get(0).path("options").get(0);
        DealOption dealOption = JsonTestUtils.deserializeJson(dealOptionNode.toString(), DealOption.class);

        byte[] bytes = SerializationTestUtils.serialize(dealOption);
        Assert.assertEquals(dealOption, SerializationTestUtils.deserialize(bytes, DealOption.class));