Search in sources :

Example 41 with EventPayload

use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.

the class DslRecordMapperTest method shouldExitFromSectionOnCondition.

@Test
public void shouldExitFromSectionOnCondition() throws IOException, InterruptedException {
    setupServer("nested-conditional-exit.groovy");
    final EventPayload event = request("http://www.example.com");
    assertEquals("happened", event.record.get("client"));
    assertEquals("happened", event.record.get("pageview"));
    assertEquals("happened", event.record.get("event"));
    assertEquals("happened", event.record.get("customCookie"));
    assertNull(event.record.get("session"));
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 42 with EventPayload

use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.

the class DslRecordMapperTest method shouldApplyBooleanLogic.

@Test
public void shouldApplyBooleanLogic() throws IOException, InterruptedException {
    setupServer("boolean-logic.groovy");
    final EventPayload event = request("http://www.example.com/");
    assertTrue((Boolean) event.record.get("unreliable"));
    assertFalse((Boolean) event.record.get("dupe"));
    assertTrue((Boolean) event.record.get("queryparamBoolean"));
    assertTrue((Boolean) event.record.get("pathBoolean"));
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 43 with EventPayload

use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.

the class DslRecordMapperTest method shouldSetCustomEventParameters.

@Test
public void shouldSetCustomEventParameters() throws IOException, InterruptedException {
    setupServer("event-param-mapping.groovy");
    final EventPayload event = request("http://www.example.com/", Collections.singletonList(HOMOGENOUS_EVENT_PARAMS));
    assertEquals(ImmutableMap.of("foo", "string", "bar", "42"), event.record.get("paramMap"));
    assertEquals("string", event.record.get("paramValue"));
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 44 with EventPayload

use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.

the class DslRecordMapperTest method shouldChainValueProducersWithIntermediateNull.

@Test
public void shouldChainValueProducersWithIntermediateNull() throws IOException, InterruptedException {
    setupServer("chained-na-mapping.groovy");
    final EventPayload event = request("http://www.exmaple.com/");
    assertEquals(new Utf8("not set"), event.record.get("queryparam"));
}
Also used : Utf8(org.apache.avro.util.Utf8) EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 45 with EventPayload

use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.

the class DslRecordMapperTest method shouldParseMinimalUri.

@Test
public void shouldParseMinimalUri() throws IOException, InterruptedException {
    /*
         * Test that URI parsing works on URIs that consist of only a path and possibly a query string.
         * This is typical for Angular style applications, where the fragment component of the location
         * is the internal location used within the angular app. In the mapping it should be possible
         * to parse the fragment of the location to a URI again and do path matching and such against
         * it.
         */
    setupServer("uri-mapping-fragment.groovy");
    final EventPayload event = request("http://example.com/path/?q=divolte#/client/side/path?x=value&y=42&q=multiple+words+%24%23%25%26");
    assertEquals("/client/side/path", event.record.get("uriPath"));
    assertEquals("x=value&y=42&q=multiple+words+%24%23%25%26", event.record.get("uriQueryString"));
    assertEquals("multiple words $#%&", event.record.get("uriQueryStringValue"));
}
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