Search in sources :

Example 6 with EventPayload

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

the class RequestChecksumTest method shouldFlagMissingChecksumAsCorrupted.

@Test
public void shouldFlagMissingChecksumAsCorrupted() throws IOException, InterruptedException {
    request(URL_QUERY_CHECKSUM_MISSING);
    Preconditions.checkState(null != server);
    final EventPayload payload = server.waitForEvent();
    assertTrue(payload.event.corruptEvent);
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 7 with EventPayload

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

the class SeleniumJavaScriptTest method shouldSignalWhenLateLoaded.

@Test
public void shouldSignalWhenLateLoaded() throws Exception {
    doSetUp();
    Preconditions.checkState(null != driver && null != server);
    // Go to the page but don't load Divolte immediately.
    gotoPage(PAGE_VIEW_DEFERRED_LOAD, false);
    final WebDriverWait wait = new WebDriverWait(driver, 30);
    final WebElement loadButton = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("load_divolte")));
    logger.info("Triggering deferred loading of Divolte");
    loadButton.click();
    // Wait for the page-view event to arrive.
    final EventPayload payload = server.waitForEvent();
    final DivolteEvent eventData = payload.event;
    assertEquals(Optional.of("pageView"), eventData.eventType);
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement) EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 8 with EventPayload

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

the class SeleniumJavaScriptTest method shouldSendCustomEvent.

@Test
public void shouldSendCustomEvent() throws Exception {
    doSetUp();
    Preconditions.checkState(null != driver && null != server);
    gotoPage(BASIC);
    server.waitForEvent();
    driver.findElement(By.id("custom")).click();
    final EventPayload payload = server.waitForEvent();
    final DivolteEvent eventData = payload.event;
    assertTrue(eventData.eventType.isPresent());
    assertEquals("custom", eventData.eventType.get());
    final Optional<String> customEventParameters = eventData.eventParametersProducer.get().map(Object::toString);
    assertTrue(customEventParameters.isPresent());
    assertEquals("{\"a\":{}," + "\"b\":\"c\"," + "\"d\":{\"a\":[],\"b\":\"g\"}," + "\"e\":[\"1\",\"2\"]," + "\"f\":42," + "\"g\":53.2," + "\"h\":-37," + "\"i\":-7.83E-9," + "\"j\":true," + "\"k\":false," + "\"l\":null," + "\"m\":\"2015-06-13T15:49:33.002Z\"," + "\"n\":{}," + "\"o\":[{},{\"a\":\"b\"},{\"c\":\"d\"}]," + "\"p\":[null,null,{\"a\":\"b\"},\"custom\",null,{}]," + "\"q\":{}}", customEventParameters.get());
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 9 with EventPayload

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

the class SeleniumJavaScriptTest method shouldUseConfiguredEventSuffix.

@Test
public void shouldUseConfiguredEventSuffix() throws Exception {
    doSetUp("selenium-test-custom-event-suffix.conf");
    Preconditions.checkState(null != server);
    gotoPage(BASIC);
    final EventPayload payload = server.waitForEvent();
    final DivolteEvent eventData = payload.event;
    assertEquals(Optional.of("pageView"), eventData.eventType);
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 10 with EventPayload

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

the class SeleniumJavaScriptTest method shouldPickupProvidedPageViewIdFromHash.

@Test
public void shouldPickupProvidedPageViewIdFromHash() throws Exception {
    doSetUp();
    Preconditions.checkState(null != server);
    gotoPage(PAGE_VIEW_SUPPLIED);
    final EventPayload payload = server.waitForEvent();
    final DivolteEvent eventData = payload.event;
    assertEquals(Optional.of("supercalifragilisticexpialidocious"), eventData.browserEventData.map(bed -> bed.pageViewId));
    assertEquals("supercalifragilisticexpialidocious0", eventData.eventId);
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) IntStream(java.util.stream.IntStream) Logger(org.slf4j.Logger) ExpectedConditions(org.openqa.selenium.support.ui.ExpectedConditions) By(org.openqa.selenium.By) LoggerFactory(org.slf4j.LoggerFactory) WebElement(org.openqa.selenium.WebElement) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) BrowserSourceConfiguration(io.divolte.server.config.BrowserSourceConfiguration) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) EventPayload(io.divolte.server.ServerTestUtils.EventPayload) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) Strings(com.google.common.base.Strings) ChronoUnit(java.time.temporal.ChronoUnit) Stream(java.util.stream.Stream) TestPages(io.divolte.server.SeleniumTestBase.TestPages) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) DUPLICATE_EVENT_KEY(io.divolte.server.IncomingRequestProcessor.DUPLICATE_EVENT_KEY) Assert(org.junit.Assert) 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