Search in sources :

Example 11 with StreamDefinition

use of org.ballerinalang.siddhi.query.api.definition.StreamDefinition in project ballerina by ballerina-lang.

the class JunctionTestCase method multiThreadedWithEventPoolTest.

@Test
public void multiThreadedWithEventPoolTest() throws InterruptedException {
    log.info("multi threaded test using event pool");
    final StreamEventPool streamEventPoolA1 = new StreamEventPool(2, 2, 2, 4);
    final StreamEventPool streamEventPoolA2 = new StreamEventPool(2, 2, 2, 4);
    final StreamEventPool streamEventPoolA3 = new StreamEventPool(2, 2, 2, 4);
    final StreamEventPool streamEventPoolB1 = new StreamEventPool(2, 2, 2, 4);
    final StreamEventPool streamEventPoolB2 = new StreamEventPool(2, 2, 2, 4);
    StreamDefinition streamA = StreamDefinition.id("streamA").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).annotation(Annotation.annotation("async"));
    StreamJunction streamJunctionA = new StreamJunction(streamA, executorService, 1024, siddhiAppContext);
    StreamJunction.Publisher streamPublisherA = streamJunctionA.constructPublisher();
    StreamDefinition streamB = StreamDefinition.id("streamB").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).annotation(Annotation.annotation("async"));
    StreamJunction streamJunctionB = new StreamJunction(streamB, executorService, 1024, siddhiAppContext);
    final StreamJunction.Publisher streamPublisherB1 = streamJunctionB.constructPublisher();
    final StreamJunction.Publisher streamPublisherB2 = streamJunctionB.constructPublisher();
    final StreamJunction.Publisher streamPublisherB3 = streamJunctionB.constructPublisher();
    StreamDefinition streamC = StreamDefinition.id("streamC").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).annotation(Annotation.annotation("async"));
    StreamJunction streamJunctionC = new StreamJunction(streamC, executorService, 1024, siddhiAppContext);
    final StreamJunction.Publisher streamPublisherC1 = streamJunctionC.constructPublisher();
    final StreamJunction.Publisher streamPublisherC2 = streamJunctionC.constructPublisher();
    StreamCallback streamCallbackA1 = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                StreamEvent innerStreamEvent = streamEventPoolA1.borrowEvent();
                innerStreamEvent.setTimestamp(streamEvent.getTimestamp());
                Object[] data = new Object[] { streamEvent.getData()[0], streamEvent.getData()[1] };
                data[0] = ((String) data[0]).concat("A1");
                innerStreamEvent.setOutputData(data);
                streamPublisherB1.send(innerStreamEvent);
            }
        }
    };
    StreamCallback streamCallbackA2 = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                StreamEvent innerStreamEvent = streamEventPoolA2.borrowEvent();
                innerStreamEvent.setTimestamp(streamEvent.getTimestamp());
                Object[] data = new Object[] { streamEvent.getData()[0], streamEvent.getData()[1] };
                data[0] = ((String) data[0]).concat("A2");
                innerStreamEvent.setOutputData(data);
                streamPublisherB2.send(innerStreamEvent);
            }
        }
    };
    StreamCallback streamCallbackA3 = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                StreamEvent innerStreamEvent = streamEventPoolA3.borrowEvent();
                innerStreamEvent.setTimestamp(streamEvent.getTimestamp());
                Object[] data = new Object[] { streamEvent.getData()[0], streamEvent.getData()[1] };
                data[0] = ((String) data[0]).concat("A3");
                innerStreamEvent.setOutputData(data);
                streamPublisherB3.send(innerStreamEvent);
            }
        }
    };
    StreamCallback streamCallbackB1 = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                StreamEvent innerStreamEvent = streamEventPoolB1.borrowEvent();
                innerStreamEvent.setTimestamp(streamEvent.getTimestamp());
                Object[] data = new Object[] { streamEvent.getData()[0], streamEvent.getData()[1] };
                data[0] = ((String) data[0]).concat("B1");
                innerStreamEvent.setOutputData(data);
                streamPublisherC1.send(innerStreamEvent);
            }
        }
    };
    StreamCallback streamCallbackB2 = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                StreamEvent innerStreamEvent = streamEventPoolB2.borrowEvent();
                innerStreamEvent.setTimestamp(streamEvent.getTimestamp());
                Object[] data = new Object[] { streamEvent.getData()[0], streamEvent.getData()[1] };
                data[0] = ((String) data[0]).concat("B2");
                innerStreamEvent.setOutputData(data);
                streamPublisherC2.send(innerStreamEvent);
            }
        }
    };
    final boolean[] eventsArrived = { false, false, false, false, false, false, false, false, false, false, false, false };
    StreamCallback streamCallbackC = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                count++;
                eventArrived = true;
                Object symbol = streamEvent.getData()[0];
                if (symbol.equals("IBMA1B1")) {
                    eventsArrived[0] = true;
                } else if (symbol.equals("IBMA1B2")) {
                    eventsArrived[1] = true;
                } else if (symbol.equals("IBMA2B1")) {
                    eventsArrived[2] = true;
                } else if (symbol.equals("IBMA2B2")) {
                    eventsArrived[3] = true;
                } else if (symbol.equals("IBMA3B1")) {
                    eventsArrived[4] = true;
                } else if (symbol.equals("IBMA3B2")) {
                    eventsArrived[5] = true;
                }
                if (symbol.equals("WSO2A1B1")) {
                    eventsArrived[6] = true;
                } else if (symbol.equals("WSO2A1B2")) {
                    eventsArrived[7] = true;
                } else if (symbol.equals("WSO2A2B1")) {
                    eventsArrived[8] = true;
                } else if (symbol.equals("WSO2A2B2")) {
                    eventsArrived[9] = true;
                } else if (symbol.equals("WSO2A3B1")) {
                    eventsArrived[10] = true;
                } else if (symbol.equals("WSO2A3B2")) {
                    eventsArrived[11] = true;
                }
            }
        }
    };
    streamJunctionA.subscribe(streamCallbackA1);
    streamJunctionA.subscribe(streamCallbackA2);
    streamJunctionA.subscribe(streamCallbackA3);
    streamJunctionA.startProcessing();
    streamJunctionB.subscribe(streamCallbackB1);
    streamJunctionB.subscribe(streamCallbackB2);
    streamJunctionB.startProcessing();
    streamJunctionC.subscribe(streamCallbackC);
    streamJunctionC.startProcessing();
    StreamEvent streamEvent1 = new StreamEvent(2, 2, 2);
    streamEvent1.setTimestamp(System.currentTimeMillis());
    streamEvent1.setOutputData(new Object[] { "IBM", 12 });
    StreamEvent streamEvent2 = new StreamEvent(2, 2, 2);
    streamEvent2.setTimestamp(System.currentTimeMillis());
    streamEvent2.setOutputData(new Object[] { "WSO2", 112 });
    streamPublisherA.send(streamEvent1);
    streamPublisherA.send(streamEvent2);
    Thread.sleep(1000);
    AssertJUnit.assertTrue(eventArrived);
    AssertJUnit.assertEquals(12, count);
    for (boolean arrived : eventsArrived) {
        AssertJUnit.assertTrue(arrived);
    }
    streamJunctionA.stopProcessing();
    streamJunctionB.stopProcessing();
    streamJunctionC.stopProcessing();
}
Also used : StreamDefinition(org.ballerinalang.siddhi.query.api.definition.StreamDefinition) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) StreamEventPool(org.ballerinalang.siddhi.core.event.stream.StreamEventPool) Event(org.ballerinalang.siddhi.core.event.Event) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) StreamCallback(org.ballerinalang.siddhi.core.stream.output.StreamCallback) Test(org.testng.annotations.Test)

Example 12 with StreamDefinition

use of org.ballerinalang.siddhi.query.api.definition.StreamDefinition in project ballerina by ballerina-lang.

the class JunctionTestCase method multiThreadedTest2.

@Test
public void multiThreadedTest2() throws InterruptedException {
    log.info("multi threaded 2");
    StreamDefinition streamA = StreamDefinition.id("streamA").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).annotation(Annotation.annotation("async"));
    StreamJunction streamJunctionA = new StreamJunction(streamA, executorService, 1024, siddhiAppContext);
    StreamJunction.Publisher streamPublisherA = streamJunctionA.constructPublisher();
    StreamDefinition streamB = StreamDefinition.id("streamB").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).annotation(Annotation.annotation("async"));
    StreamJunction streamJunctionB = new StreamJunction(streamB, executorService, 1024, siddhiAppContext);
    final StreamJunction.Publisher streamPublisherB1 = streamJunctionB.constructPublisher();
    final StreamJunction.Publisher streamPublisherB2 = streamJunctionB.constructPublisher();
    final StreamJunction.Publisher streamPublisherB3 = streamJunctionB.constructPublisher();
    StreamDefinition streamC = StreamDefinition.id("streamC").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).annotation(Annotation.annotation("async"));
    StreamJunction streamJunctionC = new StreamJunction(streamC, executorService, 1024, siddhiAppContext);
    final StreamJunction.Publisher streamPublisherC1 = streamJunctionC.constructPublisher();
    final StreamJunction.Publisher streamPublisherC2 = streamJunctionC.constructPublisher();
    StreamCallback streamCallbackA1 = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                StreamEvent innerStreamEvent = new StreamEvent(2, 2, 2);
                innerStreamEvent.setTimestamp(streamEvent.getTimestamp());
                Object[] data = new Object[] { streamEvent.getData()[0], streamEvent.getData()[1] };
                data[0] = ((String) data[0]).concat("A1");
                innerStreamEvent.setOutputData(data);
                streamPublisherB1.send(innerStreamEvent);
            }
        }
    };
    StreamCallback streamCallbackA2 = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                StreamEvent innerStreamEvent = new StreamEvent(2, 2, 2);
                innerStreamEvent.setTimestamp(streamEvent.getTimestamp());
                Object[] data = new Object[] { streamEvent.getData()[0], streamEvent.getData()[1] };
                data[0] = ((String) data[0]).concat("A2");
                innerStreamEvent.setOutputData(data);
                streamPublisherB2.send(innerStreamEvent);
            }
        }
    };
    StreamCallback streamCallbackA3 = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                StreamEvent innerStreamEvent = new StreamEvent(2, 2, 2);
                innerStreamEvent.setTimestamp(streamEvent.getTimestamp());
                Object[] data = new Object[] { streamEvent.getData()[0], streamEvent.getData()[1] };
                data[0] = ((String) data[0]).concat("A3");
                innerStreamEvent.setOutputData(data);
                streamPublisherB3.send(innerStreamEvent);
            }
        }
    };
    StreamCallback streamCallbackB1 = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                StreamEvent innerStreamEvent = new StreamEvent(2, 2, 2);
                innerStreamEvent.setTimestamp(streamEvent.getTimestamp());
                Object[] data = new Object[] { streamEvent.getData()[0], streamEvent.getData()[1] };
                data[0] = ((String) data[0]).concat("B1");
                innerStreamEvent.setOutputData(data);
                streamPublisherC1.send(innerStreamEvent);
            }
        }
    };
    StreamCallback streamCallbackB2 = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                StreamEvent innerStreamEvent = new StreamEvent(2, 2, 2);
                innerStreamEvent.setTimestamp(streamEvent.getTimestamp());
                Object[] data = new Object[] { streamEvent.getData()[0], streamEvent.getData()[1] };
                data[0] = ((String) data[0]).concat("B2");
                innerStreamEvent.setOutputData(data);
                streamPublisherC2.send(innerStreamEvent);
            }
        }
    };
    final boolean[] eventsArrived = { false, false, false, false, false, false, false, false, false, false, false, false };
    StreamCallback streamCallbackC = new StreamCallback() {

        @Override
        public void receive(Event[] streamEvents) {
            for (Event streamEvent : streamEvents) {
                count++;
                eventArrived = true;
                Object symbol = streamEvent.getData()[0];
                if (symbol.equals("IBMA1B1")) {
                    eventsArrived[0] = true;
                } else if (symbol.equals("IBMA1B2")) {
                    eventsArrived[1] = true;
                } else if (symbol.equals("IBMA2B1")) {
                    eventsArrived[2] = true;
                } else if (symbol.equals("IBMA2B2")) {
                    eventsArrived[3] = true;
                } else if (symbol.equals("IBMA3B1")) {
                    eventsArrived[4] = true;
                } else if (symbol.equals("IBMA3B2")) {
                    eventsArrived[5] = true;
                }
                if (symbol.equals("WSO2A1B1")) {
                    eventsArrived[6] = true;
                } else if (symbol.equals("WSO2A1B2")) {
                    eventsArrived[7] = true;
                } else if (symbol.equals("WSO2A2B1")) {
                    eventsArrived[8] = true;
                } else if (symbol.equals("WSO2A2B2")) {
                    eventsArrived[9] = true;
                } else if (symbol.equals("WSO2A3B1")) {
                    eventsArrived[10] = true;
                } else if (symbol.equals("WSO2A3B2")) {
                    eventsArrived[11] = true;
                }
            }
        }
    };
    streamJunctionA.subscribe(streamCallbackA1);
    streamJunctionA.subscribe(streamCallbackA2);
    streamJunctionA.subscribe(streamCallbackA3);
    streamJunctionA.startProcessing();
    streamJunctionB.subscribe(streamCallbackB1);
    streamJunctionB.subscribe(streamCallbackB2);
    streamJunctionB.startProcessing();
    streamJunctionC.subscribe(streamCallbackC);
    streamJunctionC.startProcessing();
    StreamEvent streamEvent1 = new StreamEvent(2, 2, 2);
    streamEvent1.setTimestamp(System.currentTimeMillis());
    streamEvent1.setOutputData(new Object[] { "IBM", 12 });
    StreamEvent streamEvent2 = new StreamEvent(2, 2, 2);
    streamEvent2.setTimestamp(System.currentTimeMillis());
    streamEvent2.setOutputData(new Object[] { "WSO2", 112 });
    streamPublisherA.send(streamEvent1);
    streamPublisherA.send(streamEvent2);
    Thread.sleep(100);
    AssertJUnit.assertTrue(eventArrived);
    AssertJUnit.assertEquals(12, count);
    for (boolean arrived : eventsArrived) {
        AssertJUnit.assertTrue(arrived);
    }
    streamJunctionA.stopProcessing();
    streamJunctionB.stopProcessing();
    streamJunctionC.stopProcessing();
}
Also used : StreamDefinition(org.ballerinalang.siddhi.query.api.definition.StreamDefinition) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) Event(org.ballerinalang.siddhi.core.event.Event) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) StreamCallback(org.ballerinalang.siddhi.core.stream.output.StreamCallback) Test(org.testng.annotations.Test)

Example 13 with StreamDefinition

use of org.ballerinalang.siddhi.query.api.definition.StreamDefinition in project ballerina by ballerina-lang.

the class EventTestCase method testStreamEventConverter.

@Test
public void testStreamEventConverter() {
    Attribute price = new Attribute("price", Attribute.Type.DOUBLE);
    Attribute volume = new Attribute("volume", Attribute.Type.INT);
    Attribute symbol = new Attribute("symbol", Attribute.Type.STRING);
    MetaStreamEvent metaStreamEvent = new MetaStreamEvent();
    metaStreamEvent.addData(volume);
    metaStreamEvent.initializeAfterWindowData();
    metaStreamEvent.addData(price);
    metaStreamEvent.addOutputData(symbol);
    // complex attribute
    metaStreamEvent.addOutputData(null);
    StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.DOUBLE).attribute("volume", Attribute.Type.INT);
    Event event = new Event(System.currentTimeMillis(), new Object[] { "WSO2", 200, 50 });
    metaStreamEvent.addInputDefinition(streamDefinition);
    StreamEventConverter converter = StreamEventConverterFactory.constructEventConverter(metaStreamEvent);
    StreamEventPool eventPool = new StreamEventPool(metaStreamEvent, 5);
    StreamEvent borrowedEvent = eventPool.borrowEvent();
    converter.convertEvent(event, borrowedEvent);
    AssertJUnit.assertTrue(converter instanceof SelectiveStreamEventConverter);
    // volume
    AssertJUnit.assertEquals(1, borrowedEvent.getBeforeWindowData().length);
    // price
    AssertJUnit.assertEquals(1, borrowedEvent.getOnAfterWindowData().length);
    // symbol and avgPrice
    AssertJUnit.assertEquals(2, borrowedEvent.getOutputData().length);
    AssertJUnit.assertEquals(50, borrowedEvent.getBeforeWindowData()[0]);
    AssertJUnit.assertEquals(200, borrowedEvent.getOnAfterWindowData()[0]);
    AssertJUnit.assertEquals("WSO2", borrowedEvent.getOutputData()[0]);
}
Also used : StreamDefinition(org.ballerinalang.siddhi.query.api.definition.StreamDefinition) Attribute(org.ballerinalang.siddhi.query.api.definition.Attribute) SimpleStreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.SimpleStreamEventConverter) StreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.StreamEventConverter) ZeroStreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.ZeroStreamEventConverter) SelectiveStreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.SelectiveStreamEventConverter) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) StreamEventPool(org.ballerinalang.siddhi.core.event.stream.StreamEventPool) Event(org.ballerinalang.siddhi.core.event.Event) MetaStateEvent(org.ballerinalang.siddhi.core.event.state.MetaStateEvent) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) SelectiveStreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.SelectiveStreamEventConverter) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) Test(org.testng.annotations.Test)

Example 14 with StreamDefinition

use of org.ballerinalang.siddhi.query.api.definition.StreamDefinition in project ballerina by ballerina-lang.

the class EventTestCase method testUpdateMetaEvent.

@Test
public void testUpdateMetaEvent() {
    StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);
    Attribute price = new Attribute("price", Attribute.Type.FLOAT);
    Attribute volume = new Attribute("volume", Attribute.Type.INT);
    Attribute symbol = new Attribute("symbol", Attribute.Type.STRING);
    MetaStreamEvent metaStreamEvent = new MetaStreamEvent();
    metaStreamEvent.addData(volume);
    metaStreamEvent.addData(price);
    metaStreamEvent.addData(symbol);
    metaStreamEvent.initializeAfterWindowData();
    metaStreamEvent.addData(price);
    metaStreamEvent.addOutputData(symbol);
    metaStreamEvent.addOutputData(null);
    MetaStateEvent metaStateEvent = new MetaStateEvent(1);
    metaStateEvent.addEvent(metaStreamEvent);
    VariableExpressionExecutor priceVariableExpressionExecutor = new VariableExpressionExecutor(new Attribute("price", Attribute.Type.FLOAT), 0, 0);
    VariableExpressionExecutor volumeVariableExpressionExecutor = new VariableExpressionExecutor(new Attribute("volume", Attribute.Type.INT), 0, 0);
    VariableExpressionExecutor symbolVariableExpressionExecutor = new VariableExpressionExecutor(new Attribute("symbol", Attribute.Type.STRING), 0, 0);
    QueryParserHelper.reduceMetaComplexEvent(metaStateEvent);
    QueryParserHelper.updateVariablePosition(metaStateEvent, Arrays.asList(priceVariableExpressionExecutor, volumeVariableExpressionExecutor, symbolVariableExpressionExecutor));
    AssertJUnit.assertEquals(1, metaStreamEvent.getBeforeWindowData().size());
    AssertJUnit.assertEquals(1, metaStreamEvent.getOnAfterWindowData().size());
    AssertJUnit.assertEquals(2, metaStreamEvent.getOutputData().size());
    AssertJUnit.assertArrayEquals(new int[] { 0, 0, 1, 0 }, priceVariableExpressionExecutor.getPosition());
    AssertJUnit.assertArrayEquals(new int[] { 0, 0, 0, 0 }, volumeVariableExpressionExecutor.getPosition());
    AssertJUnit.assertArrayEquals(new int[] { 0, 0, 2, 0 }, symbolVariableExpressionExecutor.getPosition());
}
Also used : StreamDefinition(org.ballerinalang.siddhi.query.api.definition.StreamDefinition) Attribute(org.ballerinalang.siddhi.query.api.definition.Attribute) VariableExpressionExecutor(org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) MetaStateEvent(org.ballerinalang.siddhi.core.event.state.MetaStateEvent) Test(org.testng.annotations.Test)

Example 15 with StreamDefinition

use of org.ballerinalang.siddhi.query.api.definition.StreamDefinition in project ballerina by ballerina-lang.

the class EventTestCase method testSimpleStreamEventConverter.

@Test
public void testSimpleStreamEventConverter() {
    Attribute price = new Attribute("price", Attribute.Type.DOUBLE);
    Attribute symbol = new Attribute("symbol", Attribute.Type.STRING);
    MetaStreamEvent metaStreamEvent = new MetaStreamEvent();
    metaStreamEvent.addOutputData(symbol);
    metaStreamEvent.addOutputData(price);
    StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.DOUBLE).attribute("volume", Attribute.Type.INT);
    Event event = new Event(System.currentTimeMillis(), new Object[] { "WSO2", 200, 50 });
    metaStreamEvent.addInputDefinition(streamDefinition);
    StreamEventConverter converter = StreamEventConverterFactory.constructEventConverter(metaStreamEvent);
    StreamEventPool eventPool = new StreamEventPool(metaStreamEvent, 5);
    StreamEvent borrowedEvent = eventPool.borrowEvent();
    converter.convertEvent(event, borrowedEvent);
    AssertJUnit.assertTrue(converter instanceof SimpleStreamEventConverter);
    AssertJUnit.assertNull(borrowedEvent.getBeforeWindowData());
    AssertJUnit.assertNull(borrowedEvent.getOnAfterWindowData());
    AssertJUnit.assertEquals(2, borrowedEvent.getOutputData().length);
    AssertJUnit.assertEquals(200, borrowedEvent.getOutputData()[1]);
    AssertJUnit.assertEquals("WSO2", borrowedEvent.getOutputData()[0]);
}
Also used : StreamDefinition(org.ballerinalang.siddhi.query.api.definition.StreamDefinition) Attribute(org.ballerinalang.siddhi.query.api.definition.Attribute) SimpleStreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.SimpleStreamEventConverter) StreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.StreamEventConverter) ZeroStreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.ZeroStreamEventConverter) SelectiveStreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.SelectiveStreamEventConverter) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) StreamEventPool(org.ballerinalang.siddhi.core.event.stream.StreamEventPool) Event(org.ballerinalang.siddhi.core.event.Event) MetaStateEvent(org.ballerinalang.siddhi.core.event.state.MetaStateEvent) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) SimpleStreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.SimpleStreamEventConverter) Test(org.testng.annotations.Test)

Aggregations

StreamDefinition (org.ballerinalang.siddhi.query.api.definition.StreamDefinition)110 Test (org.testng.annotations.Test)98 Event (org.ballerinalang.siddhi.core.event.Event)83 Query (org.ballerinalang.siddhi.query.api.execution.query.Query)82 SiddhiAppRuntime (org.ballerinalang.siddhi.core.SiddhiAppRuntime)80 SiddhiManager (org.ballerinalang.siddhi.core.SiddhiManager)80 SiddhiApp (org.ballerinalang.siddhi.query.api.SiddhiApp)80 InputHandler (org.ballerinalang.siddhi.core.stream.input.InputHandler)77 QueryCallback (org.ballerinalang.siddhi.core.query.output.callback.QueryCallback)73 StreamCallback (org.ballerinalang.siddhi.core.stream.output.StreamCallback)9 MetaStreamEvent (org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent)8 StreamEvent (org.ballerinalang.siddhi.core.event.stream.StreamEvent)8 Attribute (org.ballerinalang.siddhi.query.api.definition.Attribute)8 MetaStateEvent (org.ballerinalang.siddhi.core.event.state.MetaStateEvent)5 StreamEventPool (org.ballerinalang.siddhi.core.event.stream.StreamEventPool)5 ArrayList (java.util.ArrayList)3 SelectiveStreamEventConverter (org.ballerinalang.siddhi.core.event.stream.converter.SelectiveStreamEventConverter)3 SimpleStreamEventConverter (org.ballerinalang.siddhi.core.event.stream.converter.SimpleStreamEventConverter)3 StreamEventConverter (org.ballerinalang.siddhi.core.event.stream.converter.StreamEventConverter)3 ZeroStreamEventConverter (org.ballerinalang.siddhi.core.event.stream.converter.ZeroStreamEventConverter)3