use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldSupportPresenceTestingOfJsonPathExpressions.
@Test
public void shouldSupportPresenceTestingOfJsonPathExpressions() throws IOException, InterruptedException {
setupServer("event-param-jsonpath-presence.groovy");
final EventPayload event = request("http://www.example.com/", Collections.singletonList(HOMOGENOUS_EVENT_PARAMS));
assertTrue((Boolean) event.record.get("flag1"));
assertFalse((Boolean) event.record.get("flag2"));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldNotFailOnBrokenQueryString.
@Test
public void shouldNotFailOnBrokenQueryString() throws IOException, InterruptedException {
setupServer("funky-querystring-mapping.groovy");
final EventPayload event = request("http://example.com/path/?a=value&=42&b=&d=word&c&=bla");
/*
* Query string parsing semantics:
* ?q= => q == ""
* ?q=foo => q == "foo"
* ?q&a=bar => q == "" && a == "bar"
* ?=42&q=foo => q == "foo"
*/
assertEquals("value", event.record.get("uriQueryStringValue"));
assertEquals("", event.record.get("queryparam"));
assertEquals("", event.record.get("client"));
assertEquals("word", event.record.get("pageview"));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldPopulateFlatFields.
@Test
public void shouldPopulateFlatFields() throws InterruptedException, IOException {
setupServer("flat-mapping.groovy");
final EventPayload payload = request("https://example.com/", "http://example.com/");
final GenericRecord record = payload.record;
final DivolteEvent event = payload.event;
assertEquals(true, record.get("sessionStart"));
assertEquals(true, record.get("unreliable"));
assertEquals(false, record.get("dupe"));
assertEquals(event.requestStartTime.toEpochMilli(), record.get("ts"));
assertEquals("https://example.com/", record.get("location"));
assertEquals("http://example.com/", record.get("referer"));
assertEquals(USER_AGENT, record.get("userAgentString"));
assertEquals("Chrome", record.get("userAgentName"));
assertEquals("Chrome", record.get("userAgentFamily"));
assertEquals("Google Inc.", record.get("userAgentVendor"));
assertEquals("Browser", record.get("userAgentType"));
assertEquals("38.0.2125.122", record.get("userAgentVersion"));
assertEquals("Personal computer", record.get("userAgentDeviceCategory"));
assertEquals("OS X", record.get("userAgentOsFamily"));
assertEquals("10.10.1", record.get("userAgentOsVersion"));
assertEquals("Apple Computer, Inc.", record.get("userAgentOsVendor"));
assertEquals(event.partyId.value, record.get("client"));
assertEquals(event.sessionId.value, record.get("session"));
assertEquals(event.browserEventData.map(bed -> bed.pageViewId), Optional.of(record.get("pageview")));
assertEquals(event.eventId, record.get("event"));
assertEquals(1018, record.get("viewportWidth"));
assertEquals(1018, record.get("viewportHeight"));
assertEquals(1024, record.get("screenWidth"));
assertEquals(1024, record.get("screenHeight"));
assertEquals(2, record.get("pixelRatio"));
assertEquals("pageView", record.get("eventType"));
Stream.of("sessionStart", "unreliable", "dupe", "ts", "location", "referer", "userAgentString", "userAgentName", "userAgentFamily", "userAgentVendor", "userAgentType", "userAgentVersion", "userAgentDeviceCategory", "userAgentOsFamily", "userAgentOsVersion", "userAgentOsVendor", "client", "session", "pageview", "event", "viewportWidth", "viewportHeight", "screenWidth", "screenHeight", "pixelRatio", "eventType").forEach((v) -> assertNotNull(record.get(v)));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldMatchRegexAndExtractGroups.
@Test
public void shouldMatchRegexAndExtractGroups() throws IOException, InterruptedException {
setupServer("regex-mapping.groovy");
final EventPayload event = request("http://www.example.com/path/with/42/about.html", "http://www.example.com/path/with/13/contact.html");
assertEquals(true, event.record.get("pathBoolean"));
assertEquals("42", event.record.get("client"));
assertEquals("about", event.record.get("pageview"));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldApplyActionsInClosureWhenEqualToConditionHolds.
@Test
public void shouldApplyActionsInClosureWhenEqualToConditionHolds() throws IOException, InterruptedException {
setupServer("when-mapping.groovy");
final EventPayload event = request("http://www.example.com/", "http://www.example.com/somepage.html");
assertEquals("locationmatch", event.record.get("eventType"));
assertEquals("referermatch", event.record.get("client"));
assertEquals(new Utf8("not set"), event.record.get("queryparam"));
assertEquals("absent", event.record.get("event"));
assertEquals("present", event.record.get("pageview"));
}
Aggregations