@Test public void getUsefulTimestampFormat() { SushiAttribute rootAttribute4 = new SushiAttribute("Driver", SushiAttributeTypeEnum.STRING); SushiAttribute rootAttribute5 = new SushiAttribute("Location", SushiAttributeTypeEnum.STRING); List<SushiAttribute> attributes2 = Arrays.asList(rootAttribute4, rootAttribute5); SushiEventType eventType2 = new SushiEventType("obuEvent", attributes2, "Timestamp"); Broker.send(eventType2); loadData(eventType2, obuEventsFile); SushiQuery query = new SushiQuery( "timestamp", "select formatDate(Timestamp, 'yyyy-MM-dd HH:mm:ss') from obuEventWindow", SushiQueryTypeEnum.ONDEMAND); String result = query.execute(); System.out.println(result); }
@Test public void getAggregtedEventsFromEsper() { SushiAttribute rootAttribute4 = new SushiAttribute("Driver", SushiAttributeTypeEnum.STRING); SushiAttribute rootAttribute5 = new SushiAttribute("Location", SushiAttributeTypeEnum.STRING); List<SushiAttribute> attributes2 = Arrays.asList(rootAttribute4, rootAttribute5); SushiEventType eventType2 = new SushiEventType("obuEvent", attributes2, "Timestamp"); Broker.send(eventType2); loadData(eventType2, obuEventsFile); SushiQuery queryRome = new SushiQuery( "rome", "select count(*) from obuEventWindow where Driver = 'Paul' AND Location = 'Rome'", SushiQueryTypeEnum.ONDEMAND); String result = queryRome.execute(); String number = (String) result.subSequence(result.indexOf("=") + 1, result.indexOf("}")); System.out.println(number); }