use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldMapClientTimestamp.
@Test
public void shouldMapClientTimestamp() throws IOException, InterruptedException {
setupServer("client-timestamp.groovy");
final EventPayload event = request("https://example.com/", "http://example.com/");
final GenericRecord record = event.record;
assertEquals(ClientSideCookieEventHandler.tryParseBase36Long(CLIENT_SIDE_TIME), record.get("ts"));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldExtractJsonPathFromCustomEventParameters.
@Test
public void shouldExtractJsonPathFromCustomEventParameters() throws IOException, InterruptedException {
setupServer("event-param-jsonpath-mapping.groovy");
final EventPayload event = request("http://www.example.com/", Collections.singletonList(HETEROGENOUS_EVENT_PARAMS));
assertEquals("string", event.record.get("paramValue"));
assertEquals(42, event.record.get("paramIntValue"));
assertEquals(Arrays.asList(1.23, 0.89), event.record.get("itemPrices"));
// Doing a proper check would require accessing the schema and building everything by hand.
// This is simpler and sufficient for the purposes of testing.
assertEquals("[{\"name\": \"apple\", \"count\": 3, \"price\": 1.23}, {\"name\": \"pear\", \"count\": 1, \"price\": 0.89}]", GenericData.get().toString(event.record.get("items")));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldTreatEmptyJsonPathResultAsNonPresent.
@Test
public void shouldTreatEmptyJsonPathResultAsNonPresent() throws IOException, InterruptedException {
setupServer("event-param-jsonpath-missing.groovy");
final EventPayload event = request("http://www.example.com/");
assertEquals("value that should not be overwritten", event.record.get("paramValue"));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldSetCustomHeaders.
@Test
public void shouldSetCustomHeaders() throws IOException, InterruptedException {
setupServer("header-mapping.groovy");
final EventPayload event = request("http://www.example.com/");
assertEquals(Arrays.asList("first", "second", "last"), event.record.get("headerList"));
assertEquals("first", event.record.get("header"));
assertEquals("first,second,last", event.record.get("headers"));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldSetCustomCookieValue.
@Test
public void shouldSetCustomCookieValue() throws InterruptedException, IOException {
setupServer("custom-cookie-mapping.groovy");
final EventPayload event = request("http://example.com");
assertEquals("custom_cookie_value", event.record.get("customCookie"));
}
Aggregations