Android Open Source - snowplow-android-tracker Event Store Test






From Project

Back to project page snowplow-android-tracker.

License

The source code is released under:

Apache License

If you think the Android project snowplow-android-tracker listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.snowplowanalytics.snowplow.tracker.android;
/*from ww  w. j ava 2  s  .  c om*/
import android.test.AndroidTestCase;
import android.util.Log;

import com.snowplowanalytics.snowplow.tracker.android.payload.SchemaPayload;
import com.snowplowanalytics.snowplow.tracker.android.payload.TrackerPayload;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class EventStoreTest extends AndroidTestCase {

    public void testInsertPayload() throws Exception {
        TrackerPayload trackerPayload = new TrackerPayload();
        SchemaPayload schemaPayload = new SchemaPayload();
        trackerPayload.add("someKey", "someValue");
        trackerPayload.add("anotherKey", "anotherValue");
        schemaPayload.setSchema("iglu:com.snowplowanalytics.snowplow/example/jsonschema/1-0-0");
        schemaPayload.setData(trackerPayload);

        EventStore eventStore = new EventStore(getContext());
        long id = eventStore.insertPayload(schemaPayload);
        Map<String, Object> map = eventStore.getEvent(id);

        Log.d("EventStoreTest", map.get(EventStoreHelper.METADATA_EVENT_DATA).toString());
    }

    public void testGetPending() throws Exception {
        EventStore eventStore = new EventStore(getContext());
        List<Map<String, Object>> foo = eventStore.getAllNonPendingEvents();
        for (Map<String, Object> event : foo) {
            Log.d("EventStoreTest", event.toString());
        }
    }

    public void testRemoveAllEvents() throws Exception {
        EventStore eventStore = new EventStore(getContext());
        eventStore.removeAllEvents();
    }

    public void testSetPending() throws Exception {
        TrackerPayload trackerPayload = new TrackerPayload();
        SchemaPayload schemaPayload = new SchemaPayload();
        trackerPayload.add("someKey", "somethingElse");
        trackerPayload.add("anotherKey", "anotherSomethingElse");
        schemaPayload.setSchema("iglu:com.snowplowanalytics.snowplow/example/jsonschema/1-0-0");
        schemaPayload.setData(trackerPayload);

        EventStore eventStore = new EventStore(getContext());
        long id = eventStore.insertPayload(schemaPayload);
        eventStore.setPending(id);
    }
}




Java Source Code List

com.snowplowanalytics.snowplow.tracker.android.ApplicationTest.java
com.snowplowanalytics.snowplow.tracker.android.Constants.java
com.snowplowanalytics.snowplow.tracker.android.EventStoreHelper.java
com.snowplowanalytics.snowplow.tracker.android.EventStoreTest.java
com.snowplowanalytics.snowplow.tracker.android.EventStore.java
com.snowplowanalytics.snowplow.tracker.android.Parameter.java
com.snowplowanalytics.snowplow.tracker.android.Subject.java
com.snowplowanalytics.snowplow.tracker.android.Tracker.java
com.snowplowanalytics.snowplow.tracker.android.Util.java
com.snowplowanalytics.snowplow.tracker.android.Version.java
com.snowplowanalytics.snowplow.tracker.android.emitter.EmitterTest.java
com.snowplowanalytics.snowplow.tracker.android.emitter.Emitter.java
com.snowplowanalytics.snowplow.tracker.android.payload.SchemaPayload.java
com.snowplowanalytics.snowplow.tracker.android.payload.TrackerPayload.java