private void runAssertionSubquerySelectStar(Object[] rowValues) {
    String eplFiltered =
        "select (select * from MyTable where key = 'G1') as mt from SupportBean_S2";
    runAssertionSubquerySelectStar(rowValues, eplFiltered);

    String eplUnfiltered = "select (select * from MyTable) as mt from SupportBean_S2";
    runAssertionSubquerySelectStar(rowValues, eplUnfiltered);

    // With @eventbean
    String eplEventBean = "select (select * from MyTable) @eventbean as mt from SupportBean_S2";
    EPStatement stmt = epService.getEPAdministrator().createEPL(eplEventBean);
    stmt.addListener(listener);
    assertEquals(Object[][].class, stmt.getEventType().getPropertyType("mt"));
    assertSame(
        getTablePublicType("MyTable"), stmt.getEventType().getFragmentType("mt").getFragmentType());

    epService.getEPRuntime().sendEvent(new SupportBean_S2(0));
    EventBean event = listener.assertOneGetNewAndReset();
    Object[][] value = (Object[][]) event.get("mt");
    assertEventUnd(value[0], rowValues);
    assertSame(
        getTablePublicType("MyTable"), ((EventBean[]) event.getFragment("mt"))[0].getEventType());

    stmt.destroy();
  }
  public void testSchemaXMLWSchemaWithRestriction() throws Exception {
    Configuration config = SupportConfigFactory.getConfiguration();
    ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM();
    eventTypeMeta.setRootElementName("order");
    InputStream schemaStream =
        TestSchemaXMLEvent.class
            .getClassLoader()
            .getResourceAsStream(CLASSLOADER_SCHEMA_WITH_RESTRICTION_URI);
    assertNotNull(schemaStream);
    String schemaText = ParserTool.linesToText(ParserTool.readFile(schemaStream));
    eventTypeMeta.setSchemaText(schemaText);
    config.addEventType("OrderEvent", eventTypeMeta);

    epService = EPServiceProviderManager.getProvider("TestSchemaXML", config);
    epService.initialize();
    updateListener = new SupportUpdateListener();

    String text = "select order_amount from OrderEvent";
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(updateListener);

    SupportXML.sendEvent(
        epService.getEPRuntime(),
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<order>\n"
            + "<order_amount>202.1</order_amount>"
            + "</order>");
    EventBean theEvent = updateListener.getLastNewData()[0];
    assertEquals(Double.class, theEvent.get("order_amount").getClass());
    assertEquals(202.1d, theEvent.get("order_amount"));
    updateListener.reset();
  }
  private void runAssertionSingleRowFunc(Object[] rowValues) {
    // try join passing of params
    String eplJoin =
        "select "
            + this.getClass().getName()
            + ".myServiceEventBean(mt) as c0, "
            + this.getClass().getName()
            + ".myServiceObjectArray(mt) as c1 "
            + "from SupportBean_S2, MyTable as mt";
    EPStatement stmtJoin = epService.getEPAdministrator().createEPL(eplJoin);
    stmtJoin.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean_S2(0));
    EventBean result = listener.assertOneGetNewAndReset();
    assertEventUnd(result.get("c0"), rowValues);
    assertEventUnd(result.get("c1"), rowValues);
    stmtJoin.destroy();

    // try subquery
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addPlugInSingleRowFunction(
            "pluginServiceEventBean", this.getClass().getName(), "myServiceEventBean");
    String eplSubquery =
        "select (select pluginServiceEventBean(mt) from MyTable as mt) as c0 "
            + "from SupportBean_S2";
    EPStatement stmtSubquery = epService.getEPAdministrator().createEPL(eplSubquery);
    stmtSubquery.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean_S2(0));
    result = listener.assertOneGetNewAndReset();
    assertEventUnd(result.get("c0"), rowValues);
    stmtSubquery.destroy();
  }
  private void runAssertionOnSelectWindowAgg(Object[][] expectedType, Object[] rowValues) {
    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL(
                "on SupportBean_S2 select "
                    + "window(win.*) as c0,"
                    + "last(win.*) as c1, "
                    + "first(win.*) as c2, "
                    + "first(p1) as c3,"
                    + "window(p1) as c4,"
                    + "sorted(p1) as c5,"
                    + "minby(p1) as c6"
                    + " from MyTable as win");
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean_S2(0));
    EventBean event = listener.assertOneGetNewAndReset();
    for (String col : "c1,c2,c6".split(",")) {
      assertEventUnd(event.get(col), rowValues);
    }
    for (String col : "c0,c5".split(",")) {
      assertEventUnd(((Object[][]) event.get(col))[0], rowValues);
    }
    assertEquals("b", event.get("c3"));
    EPAssertionUtil.assertEqualsExactOrder(new String[] {"b"}, (String[]) event.get("c4"));

    stmt.destroy();
  }
Beispiel #5
0
  private void configureVariables() {

    provider.getEPAdministrator().getConfiguration().addVariable("myintvar", int.class, 5);

    EPStatement stmt =
        provider
            .getEPAdministrator()
            .createEPL("select propertyOne, propertyTwo, myintvar from MyEvent");

    // send an event
    Map<String, Object> eventData = new HashMap<String, Object>();
    eventData.put("propertyOne", "value");
    eventData.put("propertyTwo", 10);
    provider.getEPRuntime().sendEvent(eventData, "MyEvent");

    // the statement above keeps the last event for iterating
    EventBean received = stmt.iterator().next();
    System.out.println("\nConfigure Variables:");
    System.out.println(
        "Received:"
            + " propertyOne="
            + received.get("propertyOne")
            + " propertyTwo="
            + received.get("propertyTwo")
            + " myintvar="
            + received.get("myintvar"));
  }
  public Object get(EventBean obj) throws PropertyAccessException {
    // The underlying is expected to be a map
    if (!(obj.getUnderlying() instanceof Node)) {
      throw new PropertyAccessException(
          "Mismatched property getter to event bean type, "
              + "the underlying data object is not of type Node");
    }

    Node node = (Node) obj.getUnderlying();

    Node[] result = getter.getValueAsNodeArray(node);
    if (result == null) {
      return null;
    }

    Object array = Array.newInstance(componentType, result.length);
    for (int i = 0; i < result.length; i++) {
      String text = result[i].getTextContent();
      if ((text == null) || (text.length() == 0)) {
        continue;
      }

      Object parseResult = parser.parse(text);
      Array.set(array, i, parseResult);
    }

    return array;
  }
Beispiel #7
0
 private void assertConcat(String c1, String c2, String c3) {
   EventBean event = testListener.getLastNewData()[0];
   assertEquals(c1, event.get("c1"));
   assertEquals(c2, event.get("c2"));
   assertEquals(c3, event.get("c3"));
   testListener.reset();
 }
  public void testJoinSelect() {
    String eventA = SupportBean.class.getName();
    String eventB = SupportBean.class.getName();

    String joinStatement =
        "select s0.doubleBoxed, s1.intPrimitive*s1.intBoxed/2.0 as div from "
            + eventA
            + "(theString='s0').win:length(3) as s0,"
            + eventB
            + "(theString='s1').win:length(3) as s1"
            + " where s0.doubleBoxed = s1.doubleBoxed";

    EPStatement joinView = epService.getEPAdministrator().createEPL(joinStatement);
    joinView.addListener(updateListener);

    EventType result = joinView.getEventType();
    assertEquals(Double.class, result.getPropertyType("s0.doubleBoxed"));
    assertEquals(Double.class, result.getPropertyType("div"));
    assertEquals(2, joinView.getEventType().getPropertyNames().length);

    assertNull(updateListener.getLastNewData());

    sendEvent("s0", 1, 4, 5);
    sendEvent("s1", 1, 3, 2);

    EventBean[] newEvents = updateListener.getLastNewData();
    assertEquals(1d, newEvents[0].get("s0.doubleBoxed"));
    assertEquals(3d, newEvents[0].get("div"));

    Iterator<EventBean> iterator = joinView.iterator();
    EventBean theEvent = iterator.next();
    assertEquals(1d, theEvent.get("s0.doubleBoxed"));
    assertEquals(3d, theEvent.get("div"));
  }
Beispiel #9
0
  public void update(EventBean[] newData, EventBean[] oldData) {
    List<String> rank = new ArrayList<String>();
    List<Long> counts = new ArrayList<Long>();
    long pickupDate = 0;
    long dropoffDate = 0;
    long ts = 0;
    for (EventBean e : newData) {
      CountEvent c = (CountEvent) e.getUnderlying();
      rank.add(c.getRouteCode());
      counts.add(c.getCount());
      if (ts < c.getTs()) {
        pickupDate = c.getPickupDate();
        dropoffDate = c.getDropoffDate();
        ts = c.getTs();
      }
    }

    if (!rank.isEmpty()) {
      RankEvent ev = new RankEvent();
      ev.setRank(rank);
      ev.setCounts(counts);
      ev.setDropoffDate(dropoffDate);
      ev.setPickupDate(pickupDate);
      ev.setTs(ts);
      cepRT.sendEvent(ev);
    }
  }
Beispiel #10
0
 public Object getUnderlying() {
   // If wrapper is simply for the underlyingg with no additional properties, then return the
   // underlying type
   if (map.isEmpty()) {
     return event.getUnderlying();
   } else {
     return new Pair<Object, Map>(event.getUnderlying(), map);
   }
 }
Beispiel #11
0
 public void update(EventBean[] newEvents, EventBean[] oldEvents) {
   if (newEvents != null) {
     System.out.println("\nResult: ");
     for (EventBean eb : newEvents) {
       System.out.println("a=" + eb.get("a") + " b=" + eb.get("b"));
     }
     System.out.println();
   }
 }
Beispiel #12
0
 public void update(EventBean[] newEvents, EventBean[] oldEvents) {
   if (newEvents != null) {
     System.out.println();
     System.out.println("Trigger On Select:");
     System.out.println("There is " + newEvents.length + " OnUpdateEvent in OnUpdateWindow!");
     for (EventBean eb : newEvents) {
       System.out.println(eb.getUnderlying());
     }
   }
 }
Beispiel #13
0
 public void testGetPropertyType() {
   assertEquals(
       String.class,
       nested[0].getPropertyType(
           (BeanEventType) event.getEventType(), SupportEventAdapterService.getService()));
   assertEquals(
       String.class,
       nested[1].getPropertyType(
           (BeanEventType) event.getEventType(), SupportEventAdapterService.getService()));
 }
 @Override
 public void update(EventBean[] newEvents, EventBean[] oldEvents) {
   if (newEvents != null) {
     for (EventBean eb : newEvents) {
       System.out.println(eb.getUnderlying());
     }
   } else {
     System.out.println("newEvent is null");
   }
 }
  private synchronized void addEvent(EventBean eventBean) {
    String key = eventBean.get(keyPropertyName.toString()).toString();
    MarketDataEvent marketDataEvent = new MarketDataEvent();
    marketDataEvent.setSymbol(key);
    marketDataEvent.setPrice(new Double(eventBean.get("avg(price)").toString()));
    marketDataEvent.setAsk(new Double(eventBean.get("avg(ask)").toString()));
    marketDataEvent.setBid(new Double(eventBean.get("avg(bid)").toString()));

    store.put(key, marketDataEvent);
  }
Beispiel #16
0
  public Object evaluateEnumMethod(
      Collection target, boolean isNewData, ExprEvaluatorContext context) {
    if (target == null) {
      return null;
    }

    Collection set;
    if (scalar) {
      set = evaluator.evaluateGetROCollectionScalar(events, isNewData, context);
    } else {
      set = evaluator.evaluateGetROCollectionEvents(events, isNewData, context);
    }

    if (set == null || set.isEmpty() || target.isEmpty()) {
      return target;
    }

    if (scalar) {
      ArrayList<Object> result = new ArrayList<Object>(target);
      result.removeAll(set);
      return result;
    }

    Collection<EventBean> targetEvents = (Collection<EventBean>) target;
    Collection<EventBean> sourceEvents = (Collection<EventBean>) set;
    ArrayList<EventBean> result = new ArrayList<EventBean>();

    // we compare event underlying
    for (EventBean targetEvent : targetEvents) {
      if (targetEvent == null) {
        result.add(null);
        continue;
      }

      boolean found = false;
      for (EventBean sourceEvent : sourceEvents) {
        if (targetEvent == sourceEvent) {
          found = true;
          break;
        }
        if (sourceEvent == null) {
          continue;
        }
        if (targetEvent.getUnderlying().equals(sourceEvent.getUnderlying())) {
          found = true;
          break;
        }
      }

      if (!found) {
        result.add(targetEvent);
      }
    }
    return result;
  }
Beispiel #17
0
  public void testInsertIntoPlusPattern() {
    String stmtOneTxt =
        "insert into InZone "
            + "select 111 as statementId, mac, locationReportId "
            + "from "
            + SupportRFIDEvent.class.getName()
            + " "
            + "where mac in ('1','2','3') "
            + "and zoneID = '10'";
    EPStatement stmtOne = epService.getEPAdministrator().createEPL(stmtOneTxt);
    SupportUpdateListener listenerOne = new SupportUpdateListener();
    stmtOne.addListener(listenerOne);

    String stmtTwoTxt =
        "insert into OutOfZone "
            + "select 111 as statementId, mac, locationReportId "
            + "from "
            + SupportRFIDEvent.class.getName()
            + " "
            + "where mac in ('1','2','3') "
            + "and zoneID != '10'";
    EPStatement stmtTwo = epService.getEPAdministrator().createEPL(stmtTwoTxt);
    SupportUpdateListener listenerTwo = new SupportUpdateListener();
    stmtTwo.addListener(listenerTwo);

    String stmtThreeTxt =
        "select 111 as eventSpecId, A.locationReportId as locationReportId "
            + " from pattern [every A=InZone -> (timer:interval(1 sec) and not OutOfZone(mac=A.mac))]";
    EPStatement stmtThree = epService.getEPAdministrator().createEPL(stmtThreeTxt);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmtThree.addListener(listener);

    // try the alert case with 1 event for the mac in question
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    epService.getEPRuntime().sendEvent(new SupportRFIDEvent("LR1", "1", "10"));
    assertFalse(listener.isInvoked());
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(1000));

    EventBean theEvent = listener.assertOneGetNewAndReset();
    assertEquals("LR1", theEvent.get("locationReportId"));

    listenerOne.reset();
    listenerTwo.reset();

    // try the alert case with 2 events for zone 10 within 1 second for the mac in question
    epService.getEPRuntime().sendEvent(new SupportRFIDEvent("LR2", "2", "10"));
    assertFalse(listener.isInvoked());
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(1500));
    epService.getEPRuntime().sendEvent(new SupportRFIDEvent("LR3", "2", "10"));
    assertFalse(listener.isInvoked());
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(2000));

    theEvent = listener.assertOneGetNewAndReset();
    assertEquals("LR2", theEvent.get("locationReportId"));
  }
  public void testSchemaXMLWSchemaWithAll() throws Exception {
    Configuration config = SupportConfigFactory.getConfiguration();
    ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM();
    eventTypeMeta.setRootElementName("event-page-visit");
    String schemaUri =
        TestSchemaXMLEvent.class
            .getClassLoader()
            .getResource(CLASSLOADER_SCHEMA_WITH_ALL_URI)
            .toString();
    eventTypeMeta.setSchemaResource(schemaUri);
    eventTypeMeta.addNamespacePrefix("ss", "samples:schemas:simpleSchemaWithAll");
    eventTypeMeta.addXPathProperty("url", "/ss:event-page-visit/ss:url", XPathConstants.STRING);
    config.addEventType("PageVisitEvent", eventTypeMeta);

    epService = EPServiceProviderManager.getProvider("TestSchemaXML", config);
    epService.initialize();
    updateListener = new SupportUpdateListener();

    // url='page4'
    String text = "select a.url as sesja from pattern [ every a=PageVisitEvent(url='page1') ]";
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(updateListener);

    SupportXML.sendEvent(
        epService.getEPRuntime(),
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n"
            + "<url>page1</url>"
            + "</event-page-visit>");
    EventBean theEvent = updateListener.getLastNewData()[0];
    assertEquals("page1", theEvent.get("sesja"));
    updateListener.reset();

    SupportXML.sendEvent(
        epService.getEPRuntime(),
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n"
            + "<url>page2</url>"
            + "</event-page-visit>");
    assertFalse(updateListener.isInvoked());

    EventType type =
        epService.getEPAdministrator().createEPL("select * from PageVisitEvent").getEventType();
    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {
          new EventPropertyDescriptor(
              "sessionId", Node.class, null, false, false, false, false, true),
          new EventPropertyDescriptor(
              "customerId", Node.class, null, false, false, false, false, true),
          new EventPropertyDescriptor("url", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("method", Node.class, null, false, false, false, false, true),
        },
        type.getPropertyDescriptors());
  }
  public void testGetCombined() {
    assertEquals("0ma0", eventBeanCombined.get("indexed[0].mapped('0ma').value"));
    assertEquals("0ma1", eventBeanCombined.get("indexed[0].mapped('0mb').value"));
    assertEquals("1ma0", eventBeanCombined.get("indexed[1].mapped('1ma').value"));
    assertEquals("1ma1", eventBeanCombined.get("indexed[1].mapped('1mb').value"));

    assertEquals("0ma0", eventBeanCombined.get("array[0].mapped('0ma').value"));
    assertEquals("1ma1", eventBeanCombined.get("array[1].mapped('1mb').value"));

    assertMap(eventBeanCombined);
  }
Beispiel #20
0
  public void testGetGetter() {
    EventPropertyGetter getter =
        nested[0].getGetter(
            (BeanEventType) event.getEventType(), SupportEventAdapterService.getService());
    assertEquals("nestedValue", getter.get(event));

    getter =
        nested[1].getGetter(
            (BeanEventType) event.getEventType(), SupportEventAdapterService.getService());
    assertEquals("nestedNestedValue", getter.get(event));
  }
Beispiel #21
0
 public static final void readNamedWindow(EPServiceProvider provider) {
   EPStatement statement =
       provider
           .getEPAdministrator()
           .createEPL(properties.getProperty("deposit.window.named1.select"));
   Iterator<EventBean> iterator = statement.iterator();
   while (iterator.hasNext()) {
     EventBean bean = iterator.next();
     System.out.println(bean.get("accountName"));
   }
 }
 private void assertEvent(Map<String, Map<String, String>> last, EventBean eventBean, int count) {
   String error = "Error asseting count " + count;
   String key = (String) eventBean.get("k0");
   Map<String, String> vals = last.get(key);
   assertEquals(error, vals.get("p0"), eventBean.get("p0"));
   assertEquals(error, vals.get("p1"), eventBean.get("p1"));
   assertEquals(error, vals.get("p2"), eventBean.get("p2"));
   assertEquals(error, vals.get("p3"), eventBean.get("p3"));
   assertEquals(error, vals.get("p4"), eventBean.get("p4"));
   assertEquals(error, vals.get("p5"), eventBean.get("p5"));
 }
    @Override
    public void update(EventBean[] newEvents, EventBean[] oldEvents) {
      for (EventBean eventBean : newEvents) {
        Double averageTimeTaken = (Double) eventBean.get("avg(timeTakenForRequest)");
        if (averageTimeTaken == null) {
          break;
        }
        String providerName = (String) eventBean.get("providerName");

        System.out.println(providerName + " " + averageTimeTaken);
      }
    }
  public void update(EventBean[] newEvents, EventBean[] oldEvents) {
    EventBean event = newEvents[0];
    Integer id = (Integer) event.get("field_id");
    Double result = (Double) event.get("AggregatedResult");

    // AVG of 3 values: id and id^2 and id^3
    assertEquals("For field_id=" + id, (id + id * id + id * id * id) / 3., result, 1.e-06);

    count++;
    if (newEvents != null) newCount += newEvents.length;
    if (oldEvents != null) oldCount += oldEvents.length;
  }
  private void runAssertionSubquerySelectStar(Object[] rowValues, String epl) {
    EPStatement stmt = epService.getEPAdministrator().createEPL(epl);
    stmt.addListener(listener);

    assertEquals(Object[].class, stmt.getEventType().getPropertyType("mt"));

    epService.getEPRuntime().sendEvent(new SupportBean_S2(0));
    EventBean event = listener.assertOneGetNewAndReset();
    assertEventUnd(event.get("mt"), rowValues);

    stmt.destroy();
  }
  private void runAssertionPerformance(boolean namedWindow, EventRepresentationEnum outputType) {

    String eplCreate =
        namedWindow
            ? outputType.getAnnotationText()
                + " create window MyWindow.win:keepall() as (c1 string, c2 int)"
            : "create table MyWindow(c1 string primary key, c2 int)";
    EPStatement stmtNamedWindow = epService.getEPAdministrator().createEPL(eplCreate);
    assertEquals(outputType.getOutputClass(), stmtNamedWindow.getEventType().getUnderlyingType());

    // preload events
    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL(
                "insert into MyWindow select theString as c1, intPrimitive as c2 from SupportBean");
    final int totalUpdated = 5000;
    for (int i = 0; i < totalUpdated; i++) {
      epService.getEPRuntime().sendEvent(new SupportBean("E" + i, 0));
    }
    stmt.destroy();

    String epl =
        "on SupportBean sb merge MyWindow nw where nw.c1 = sb.theString "
            + "when matched then update set nw.c2=sb.intPrimitive";
    stmt = epService.getEPAdministrator().createEPL(epl);
    stmt.addListener(mergeListener);

    // prime
    for (int i = 0; i < 100; i++) {
      epService.getEPRuntime().sendEvent(new SupportBean("E" + i, 1));
    }
    long startTime = System.currentTimeMillis();
    for (int i = 0; i < totalUpdated; i++) {
      epService.getEPRuntime().sendEvent(new SupportBean("E" + i, 1));
    }
    long endTime = System.currentTimeMillis();
    long delta = endTime - startTime;

    // verify
    Iterator<EventBean> events = stmtNamedWindow.iterator();
    int count = 0;
    for (; events.hasNext(); ) {
      EventBean next = events.next();
      assertEquals(1, next.get("c2"));
      count++;
    }
    assertEquals(totalUpdated, count);
    assertTrue("Delta=" + delta, delta < 500);

    epService.getEPAdministrator().destroyAllStatements();
    epService.getEPAdministrator().getConfiguration().removeEventType("MyWindow", true);
  }
Beispiel #27
0
  /**
   * Given an Event from the Esper core engine, get its name. This return null for UUID-based names
   * (select statements), the specified name otherwise (named streams, e.g. insert)
   *
   * @param newEvent Event to extract the name from
   * @return event name if human-readable, null otherwise
   */
  static String getEventName(EventBean newEvent) {
    String typeName = newEvent.getEventType().getName();

    // For automatically generated event names (uuid, most likely from a select statement), the
    // public name
    // is null.
    if (newEvent.getEventType() instanceof MapEventType) {
      typeName = ((MapEventType) newEvent.getEventType()).getMetadata().getPublicName();
    }

    return typeName;
  }
  public void testProcess() {
    EventBean[] testEvents = SupportStreamTypeSvc3Stream.getSampleEvents();

    EventBean result = processor.process(testEvents, true, false);
    assertEquals(testEvents[0].getUnderlying(), result.get("s0"));
    assertEquals(testEvents[1].getUnderlying(), result.get("s1"));

    // Test null events, such as in an outer join
    testEvents[1] = null;
    result = processor.process(testEvents, true, false);
    assertEquals(testEvents[0].getUnderlying(), result.get("s0"));
    assertNull(result.get("s1"));
  }
  private void runAssertionOutputSnapshot(
      Object[][] expectedType, Object[] rowValues, AtomicLong currentTime) {
    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL("select * from MyTable output snapshot every 1 second");
    stmt.addListener(listener);
    assertEventType(stmt.getEventType(), expectedType);

    currentTime.set(currentTime.get() + 1000L);
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(currentTime.get()));
    EventBean event = listener.assertOneGetNewAndReset();
    assertEventTypeAndEvent(event.getEventType(), expectedType, event.getUnderlying(), rowValues);
  }
Beispiel #30
0
  private void tryCoalesceBeans(String viewExpr) {
    epService.initialize();
    selectTestView = epService.getEPAdministrator().createEPL(viewExpr);
    selectTestView.addListener(testListener);

    SupportBean event = sendEvent("s0");
    EventBean eventReceived = testListener.assertOneGetNewAndReset();
    assertEquals("s0", eventReceived.get("myString"));
    assertSame(event, eventReceived.get("myBean"));

    event = sendEvent("s1");
    eventReceived = testListener.assertOneGetNewAndReset();
    assertEquals("s1", eventReceived.get("myString"));
    assertSame(event, eventReceived.get("myBean"));
  }