private void TryAssertionReturnTypeIsEventsInvalid(EPServiceProvider epService) { var entry = new ConfigurationPlugInSingleRowFunction(); entry.FunctionClassName = GetType().FullName; entry.FunctionMethodName = "MyItemProducerEventBeanArray"; // test invalid: no event type name entry.Name = "myItemProducerInvalidNoType"; entry.EventTypeName = null; epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction(entry); epService.EPAdministrator.CreateEPL("select MyItemProducerInvalidNoType(TheString) as c0 from SupportBean"); SupportMessageAssertUtil.TryInvalid( epService, "select MyItemProducerInvalidNoType(TheString).where(v => v.id='id1') as c0 from SupportBean", "Error starting statement: Failed to validate select-clause expression 'MyItemProducerInvalidNoType(TheStri...(68 chars)': Method 'MyItemProducerEventBeanArray' returns EventBean-array but does not provide the event type name ["); // test invalid: event type name invalid entry.Name = "myItemProducerInvalidWrongType"; entry.EventTypeName = "dummy"; epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction(entry); SupportMessageAssertUtil.TryInvalid( epService, "select MyItemProducerInvalidWrongType(TheString).where(v => v.id='id1') as c0 from SupportBean", "Error starting statement: Failed to validate select-clause expression 'MyItemProducerInvalidWrongType(TheS...(74 chars)': Method 'MyItemProducerEventBeanArray' returns event type 'dummy' and the event type cannot be found [select MyItemProducerInvalidWrongType(TheString).where(v => v.id='id1') as c0 from SupportBean]"); epService.EPAdministrator.DestroyAllStatements(); }
public void TestUDFAndScriptReturningEvents() { _epService.EPAdministrator.CreateEPL("create schema ItemEvent(id string)"); var entry = new ConfigurationPlugInSingleRowFunction(); entry.Name = "myItemProducerUDF"; entry.FunctionClassName = GetType().FullName; entry.FunctionMethodName = "MyItemProducerUDF"; entry.EventTypeName = "ItemEvent"; _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction(entry); string script = "create expression EventBean[] @Type(ItemEvent) jscript:myItemProducerScript() [\n" + " function myItemProducerScript() {" + " var eventBean = host.resolveType('com.espertech.esper.client.EventBean');\n" + " var events = host.newArr(eventBean, 2);\n" + " events[0] = epl.EventBeanService.AdapterForMap(Collections.SingletonDataMap(\"id\", \"id1\"), \"ItemEvent\");\n" + " events[1] = epl.EventBeanService.AdapterForMap(Collections.SingletonDataMap(\"id\", \"id3\"), \"ItemEvent\");\n" + " return events;\n" + " }" + " return myItemProducerScript();" + "]"; _epService.EPAdministrator.CreateEPL(script); RunAssertionUDFAndScriptReturningEvents("MyItemProducerUDF"); RunAssertionUDFAndScriptReturningEvents("myItemProducerScript"); }
public void AddPlugInSingleRowFunction(ConfigurationPlugInSingleRowFunction config) { InternalAddPlugInSingleRowFunction( config.Name, config.FunctionClassName, config.FunctionMethodName, config.ValueCache, config.FilterOptimizable, config.IsRethrowExceptions, config.EventTypeName); }
private void RunAssertionReturnTypeIsEvents(String methodName) { ConfigurationPlugInSingleRowFunction entry = new ConfigurationPlugInSingleRowFunction(); entry.Name = methodName; entry.FunctionClassName = this.GetType().FullName; entry.FunctionMethodName = methodName; entry.EventTypeName = "MyItem"; _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction(entry); _epService.EPAdministrator.CreateEPL("create schema MyItem(id string)"); EPStatement stmt = _epService.EPAdministrator.CreateEPL("select " + methodName + "(theString).where(v => v.id in ('id1', 'id3')) as c0 from SupportBean"); stmt.AddListener(_listener); _epService.EPRuntime.SendEvent(new SupportBean("id0,id1,id2,id3,id4", 0)); var coll = _listener.AssertOneGetNewAndReset().Get("c0").UnwrapIntoArray <IDictionary <string, object> >(); EPAssertionUtil.AssertPropsPerRow(coll, "id".SplitCsv(), new Object[][] { new Object[] { "id1" }, new Object[] { "id3" } }); stmt.Dispose(); }
private void TryAssertionReturnTypeIsEvents(EPServiceProvider epService, string methodName) { var entry = new ConfigurationPlugInSingleRowFunction(); entry.Name = methodName; entry.FunctionClassName = GetType().FullName; entry.FunctionMethodName = methodName; entry.EventTypeName = "MyItem"; epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction(entry); epService.EPAdministrator.CreateEPL("create schema MyItem(id string)"); var stmt = epService.EPAdministrator.CreateEPL( "select " + methodName + "(TheString).where(v => v.id in ('id1', 'id3')) as c0 from SupportBean"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("id0,id1,id2,id3,id4", 0)); var coll = listener.AssertOneGetNewAndReset().Get("c0").UnwrapIntoArray<object>(); EPAssertionUtil.AssertPropsPerRow( SupportContainer.Instance, coll, "id".Split(','), new[] {new object[] {"id1"}, new object[] {"id3"}}); stmt.Dispose(); }