// Path: liquid/src/test/java/io/lqd/sdk/factory/FactoryGirl.java
// public class FactoryGirl {
// 
//     private static final SecureRandom random = new SecureRandom();
// 
// 
//     public static LQNetworkRequest createRequest() {
//         return new LQNetworkRequest(randomString(), "GET", randomString());
//     }
// 
//     public static LQEvent createEvent() {
//         return new LQEvent(randomString(), null);
//     }
// 
// 
//     public static LQDevice createDevice(Context c) {
//         return new LQDevice(c, Liquid.LIQUID_VERSION);
//     }
// 
//     public static LQDataPoint createDataPoint(Context c) {
//         return new LQDataPoint(createUser(), createDevice(c), createEvent(), new ArrayList<LQValue>());
//     }
// 
//     public static LQEvent createEvent(HashMap<String, Object> attrs) {
//         return new LQEvent(randomString(), attrs);
//     }
// 
//     public static LQUser createUser() {
//         return new LQUser(randomString());
//     }
// 
// 
//     private static String randomString() {
//         return new BigInteger(130, random).toString(32);
//     }
// 
// }


import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import io.lqd.sdk.LiquidTools;
import io.lqd.sdk.factory.FactoryGirl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
package io.lqd.sdk.model;






@Config(manifest = "../AndroidManifest.xml")
@RunWith(RobolectricTestRunner.class)
public class LQEventTest {

    private LQEvent event;
    private JSONObject json;

    @Test
    public void testJSONCreationWithoutAttributes() {
        event = FactoryGirl.createEvent();
        json = event.toJSON();

        assertTrue(json.has("name"));
        assertTrue(json.has("date"));
    }

    @Test
    public void testJSONCreationWithAttributes() throws JSONException {
        HashMap<String, Object> attrs = new HashMap<String, Object>();
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MINUTE, 30);
        Date now = new Date();
        attrs.put("attr1", true);
        attrs.put("attr2", "le_value");
        attrs.put("attr3", now);

        // override default event methods
        attrs.put("name", "le_name");
        attrs.put("date", LiquidTools.dateToString(cal.getTime()));

// Path: liquid/src/test/java/io/lqd/sdk/factory/FactoryGirl.java
// public class FactoryGirl {
// 
//     private static final SecureRandom random = new SecureRandom();
// 
// 
//     public static LQNetworkRequest createRequest() {
//         return new LQNetworkRequest(randomString(), "GET", randomString());
//     }
// 
//     public static LQEvent createEvent() {
//         return new LQEvent(randomString(), null);
//     }
// 
// 
//     public static LQDevice createDevice(Context c) {
//         return new LQDevice(c, Liquid.LIQUID_VERSION);
//     }
// 
//     public static LQDataPoint createDataPoint(Context c) {
//         return new LQDataPoint(createUser(), createDevice(c), createEvent(), new ArrayList<LQValue>());
//     }
// 
//     public static LQEvent createEvent(HashMap<String, Object> attrs) {
//         return new LQEvent(randomString(), attrs);
//     }
// 
//     public static LQUser createUser() {
//         return new LQUser(randomString());
//     }
// 
// 
//     private static String randomString() {
//         return new BigInteger(130, random).toString(32);
//     }
// 
// }


// Path: liquid/src/test/java/io/lqd/sdk/model/LQEventTest.java
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import io.lqd.sdk.LiquidTools;
import io.lqd.sdk.factory.FactoryGirl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;

package io.lqd.sdk.model;






@Config(manifest = "../AndroidManifest.xml")
@RunWith(RobolectricTestRunner.class)
public class LQEventTest {

    private LQEvent event;
    private JSONObject json;

    @Test
    public void testJSONCreationWithoutAttributes() {
        event = FactoryGirl.createEvent();
        json = event.toJSON();

        assertTrue(json.has("name"));
        assertTrue(json.has("date"));
    }

    @Test
    public void testJSONCreationWithAttributes() throws JSONException {
        HashMap<String, Object> attrs = new HashMap<String, Object>();
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MINUTE, 30);
        Date now = new Date();
        attrs.put("attr1", true);
        attrs.put("attr2", "le_value");
        attrs.put("attr3", now);

        // override default event methods
        attrs.put("name", "le_name");
        attrs.put("date", LiquidTools.dateToString(cal.getTime()));

        event = FactoryGirl.createEvent(attrs);