use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class SeleniumJavaScriptTest method shouldSignalWhenOpeningPage.
@Test
public void shouldSignalWhenOpeningPage() throws Exception {
doSetUp();
Preconditions.checkState(null != server);
final String location = gotoPage(BASIC);
final EventPayload payload = server.waitForEvent();
final DivolteEvent eventData = payload.event;
final Boolean detectedDuplicate = payload.event.exchange.getAttachment(DUPLICATE_EVENT_KEY);
assertFalse(eventData.corruptEvent);
assertFalse(detectedDuplicate);
assertFalse(Strings.isNullOrEmpty(eventData.partyId.value));
assertTrue(eventData.newPartyId);
assertFalse(Strings.isNullOrEmpty(eventData.sessionId.value));
assertTrue(eventData.firstInSession);
assertTrue(eventData.browserEventData.isPresent());
final DivolteEvent.BrowserEventData browserEventData = eventData.browserEventData.get();
assertFalse(Strings.isNullOrEmpty(browserEventData.pageViewId));
assertFalse(Strings.isNullOrEmpty(eventData.eventId));
assertTrue(eventData.eventType.isPresent());
assertEquals("pageView", eventData.eventType.get());
assertTrue(browserEventData.location.isPresent());
assertEquals(location, browserEventData.location.get());
/*
* We don't really know anything about the clock on the executing browser,
* but we'd expect it to be a reasonably accurate clock on the same planet.
* So, if it is within +/- 12 hours of our clock, we think it's fine.
*/
final Instant now = Instant.now();
assertThat(eventData.clientTime, allOf(greaterThan(now.minus(12, ChronoUnit.HOURS)), lessThan(now.plus(12, ChronoUnit.HOURS))));
/*
* Doing true assertions against the viewport and window size
* is problematic on different devices, as the number do not
* always make sense on SauceLabs. Also, sometimes the window
* is partially outside of the screen view port or other strange
* things. It gets additionally complicated on mobile devices.
*
* Hence, we just check whether these are integers greater than 50.
*/
assertTrue(browserEventData.viewportPixelWidth.isPresent());
assertThat(browserEventData.viewportPixelWidth.get(), greaterThan(50));
assertTrue(browserEventData.viewportPixelHeight.isPresent());
assertThat(browserEventData.viewportPixelHeight.get(), greaterThan(50));
assertTrue(browserEventData.screenPixelWidth.isPresent());
assertThat(browserEventData.screenPixelWidth.get(), greaterThan(50));
assertTrue(browserEventData.screenPixelHeight.isPresent());
assertThat(browserEventData.screenPixelHeight.get(), greaterThan(50));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class SeleniumJavaScriptTest method shouldSupportCustomJavascriptName.
@Test
public void shouldSupportCustomJavascriptName() throws Exception {
doSetUp("selenium-test-custom-javascript-name.conf");
Preconditions.checkState(null != server);
gotoPage(CUSTOM_JAVASCRIPT_NAME);
final EventPayload payload = server.waitForEvent();
final DivolteEvent eventData = payload.event;
assertEquals(Optional.of("pageView"), eventData.eventType);
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldStopWhenToldTo.
@Test
public void shouldStopWhenToldTo() throws IOException, InterruptedException {
setupServer("basic-stop.groovy");
final EventPayload event = request("http://www.example.com");
assertEquals("happened", event.record.get("client"));
assertNull(event.record.get("session"));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldParseUriComponentsRaw.
@Test
public void shouldParseUriComponentsRaw() throws IOException, InterruptedException {
setupServer("uri-mapping-raw.groovy");
final EventPayload event = request("http://example.com/path/to/resource%20and%20such/page.html?q=multiple+words+%24%23%25%26&p=42#/client/side/path?x=value&y=42&q=multiple+words+%24%23%25%26");
assertEquals("/path/to/resource%20and%20such/page.html", event.record.get("uriPath"));
assertEquals("q=multiple+words+%24%23%25%26&p=42", event.record.get("uriQueryString"));
assertEquals("/client/side/path?x=value&y=42&q=multiple+words+%24%23%25%26", event.record.get("uriFragment"));
}
use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.
the class DslRecordMapperTest method shouldMapAllEventParameters.
@Test
public void shouldMapAllEventParameters() throws IOException, InterruptedException {
setupServer("event-param-all.groovy");
final EventPayload event = request("http://www.example.com/", Collections.singletonList(HETEROGENOUS_EVENT_PARAMS));
assertEquals("{\"foo\": \"string\", \"bar\": \"42\", \"items\": [{\"count\": 3, \"price\": 1.23}, {\"count\": 1, \"price\": 0.89}]}", GenericData.get().toString(event.record.get("paramRecord")));
}
Aggregations