Search in sources :

Example 11 with EventBatch

use of com.optimizely.ab.event.internal.payload.EventBatch in project java-sdk by optimizely.

the class JsonSimpleSerializerTest method serializeConversion.

@Test
public void serializeConversion() throws IOException, ParseException {
    EventBatch conversion = generateConversion();
    // can't compare JSON strings since orders could vary so compare JSONObjects instead
    JSONObject actual = (JSONObject) parser.parse(serializer.serialize(conversion));
    JSONObject expected = (JSONObject) parser.parse(generateConversionJson());
    assertThat(actual, is(expected));
}
Also used : JSONObject(org.json.simple.JSONObject) EventBatch(com.optimizely.ab.event.internal.payload.EventBatch) Test(org.junit.Test)

Example 12 with EventBatch

use of com.optimizely.ab.event.internal.payload.EventBatch in project java-sdk by optimizely.

the class JsonSimpleSerializerTest method serializeImpressionWithSessionId.

@Test
public void serializeImpressionWithSessionId() throws IOException, ParseException {
    EventBatch impression = generateImpressionWithSessionId();
    // can't compare JSON strings since orders could vary so compare JSONObjects instead
    JSONObject actual = (JSONObject) parser.parse(serializer.serialize(impression));
    JSONObject expected = (JSONObject) parser.parse(generateImpressionWithSessionIdJson());
    assertThat(actual, is(expected));
}
Also used : JSONObject(org.json.simple.JSONObject) EventBatch(com.optimizely.ab.event.internal.payload.EventBatch) Test(org.junit.Test)

Example 13 with EventBatch

use of com.optimizely.ab.event.internal.payload.EventBatch in project java-sdk by optimizely.

the class GsonSerializerTest method serializeImpression.

@Test
public void serializeImpression() throws IOException {
    EventBatch impression = generateImpression();
    // can't compare JSON strings since orders could vary so compare objects instead
    EventBatch actual = gson.fromJson(serializer.serialize(impression), EventBatch.class);
    EventBatch expected = gson.fromJson(generateImpressionJson(), EventBatch.class);
    assertThat(actual, is(expected));
}
Also used : EventBatch(com.optimizely.ab.event.internal.payload.EventBatch) Test(org.junit.Test)

Example 14 with EventBatch

use of com.optimizely.ab.event.internal.payload.EventBatch in project java-sdk by optimizely.

the class JacksonSerializerTest method serializeImpressionWithSessionId.

@Test
public void serializeImpressionWithSessionId() throws IOException {
    EventBatch impression = generateImpressionWithSessionId();
    // can't compare JSON strings since orders could vary so compare objects instead
    EventBatch actual = mapper.readValue(serializer.serialize(impression), EventBatch.class);
    EventBatch expected = mapper.readValue(generateImpressionWithSessionIdJson(), EventBatch.class);
    assertThat(actual, is(expected));
}
Also used : EventBatch(com.optimizely.ab.event.internal.payload.EventBatch) Test(org.junit.Test)

Example 15 with EventBatch

use of com.optimizely.ab.event.internal.payload.EventBatch in project java-sdk by optimizely.

the class JsonSerializerTest method serializeConversion.

@Test
public void serializeConversion() throws IOException {
    EventBatch conversion = generateConversion();
    // can't compare JSON strings since orders could vary so compare JSONObjects instead
    JSONObject actual = new JSONObject(serializer.serialize(conversion));
    JSONObject expected = new JSONObject(generateConversionJson());
    assertTrue(actual.similar(expected));
}
Also used : JSONObject(org.json.JSONObject) EventBatch(com.optimizely.ab.event.internal.payload.EventBatch) Test(org.junit.Test)

Aggregations

EventBatch (com.optimizely.ab.event.internal.payload.EventBatch)33 Test (org.junit.Test)27 LogEvent (com.optimizely.ab.event.LogEvent)13 Experiment (com.optimizely.ab.config.Experiment)12 Variation (com.optimizely.ab.config.Variation)12 Attribute (com.optimizely.ab.config.Attribute)9 EventType (com.optimizely.ab.config.EventType)7 Bucketer (com.optimizely.ab.bucketing.Bucketer)6 ProjectConfig (com.optimizely.ab.config.ProjectConfig)6 Decision (com.optimizely.ab.event.internal.payload.Decision)6 DecisionService (com.optimizely.ab.bucketing.DecisionService)5 UserProfileService (com.optimizely.ab.bucketing.UserProfileService)5 NoOpErrorHandler (com.optimizely.ab.error.NoOpErrorHandler)5 HashMap (java.util.HashMap)5 ErrorHandler (com.optimizely.ab.error.ErrorHandler)4 JSONObject (org.json.JSONObject)4 JSONObject (org.json.simple.JSONObject)4 Snapshot (com.optimizely.ab.event.internal.payload.Snapshot)3 Visitor (com.optimizely.ab.event.internal.payload.Visitor)3 ArrayList (java.util.ArrayList)3