Search in sources :

Example 21 with EventPayload

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"));
}
Also used : GenericRecord(org.apache.avro.generic.GenericRecord) EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 22 with EventPayload

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")));
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 23 with EventPayload

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"));
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 24 with EventPayload

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"));
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 25 with EventPayload

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"));
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Aggregations

EventPayload (io.divolte.server.ServerTestUtils.EventPayload)46 Test (org.junit.Test)46 HttpURLConnection (java.net.HttpURLConnection)5 URL (java.net.URL)5 GenericRecord (org.apache.avro.generic.GenericRecord)3 Utf8 (org.apache.avro.util.Utf8)3 JsonParser (com.fasterxml.jackson.core.JsonParser)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 CityResponse (com.maxmind.geoip2.model.CityResponse)2 Config (com.typesafe.config.Config)2 ValidatedConfiguration (io.divolte.server.config.ValidatedConfiguration)2 LookupService (io.divolte.server.ip2geo.LookupService)2 DslRecordMapper (io.divolte.server.recordmapping.DslRecordMapper)2 Instant (java.time.Instant)2 Optional (java.util.Optional)2 Stream (java.util.stream.Stream)2 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)2 Assert (org.junit.Assert)2 WebElement (org.openqa.selenium.WebElement)2 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)2