use of io.siddhi.core.event.stream.converter.ConversionStreamEventChunk in project siddhi by wso2.
the class ComplexEventChunkTestCase method eventChunkTest.
@Test
public void eventChunkTest() {
StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
streamEvent1.setOutputData(new Object[] { "IBM", 700L, 1L });
StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
streamEvent2.setOutputData(new Object[] { "WSO2", 700L, 2L });
StreamEvent streamEvent3 = new StreamEvent(0, 0, 3);
streamEvent3.setOutputData(new Object[] { "WSO2", 700L, 3L });
streamEvent1.setNext(streamEvent2);
streamEvent2.setNext(streamEvent3);
StreamEventFactory streamEventFactory = new StreamEventFactory(0, 0, 3);
ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter, streamEventFactory);
streamEventChunk.convertAndAssign(streamEvent1);
while (streamEventChunk.hasNext()) {
count++;
StreamEvent event = streamEventChunk.next();
AssertJUnit.assertEquals(count * 1L, event.getOutputData()[2]);
}
AssertJUnit.assertEquals(3, count);
}
use of io.siddhi.core.event.stream.converter.ConversionStreamEventChunk in project siddhi by wso2.
the class ComplexEventChunkTestCase method eventChunkRemoveTest1.
@Test
public void eventChunkRemoveTest1() {
StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
streamEvent1.setOutputData(new Object[] { "IBM", 700L, 1L });
StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
streamEvent2.setOutputData(new Object[] { "WSO2", 700L, 2L });
StreamEvent streamEvent3 = new StreamEvent(0, 0, 3);
streamEvent3.setOutputData(new Object[] { "WSO2", 700L, 3L });
streamEvent1.setNext(streamEvent2);
streamEvent2.setNext(streamEvent3);
StreamEventFactory streamEventFactory = new StreamEventFactory(0, 0, 3);
ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter, streamEventFactory);
streamEventChunk.convertAndAssign(streamEvent1);
while (streamEventChunk.hasNext()) {
count++;
streamEventChunk.next();
if (count == 1) {
streamEventChunk.remove();
}
}
AssertJUnit.assertEquals(streamEvent2, streamEventChunk.getFirst());
}
use of io.siddhi.core.event.stream.converter.ConversionStreamEventChunk in project siddhi by wso2.
the class ComplexEventChunkTestCase method eventChunkRemoveTest5.
@Test(expectedExceptions = IllegalStateException.class)
public void eventChunkRemoveTest5() {
StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
streamEvent1.setOutputData(new Object[] { "IBM", 700L, 100L });
StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
streamEvent2.setOutputData(new Object[] { "WSO2", 700L, 100L });
streamEvent1.setNext(streamEvent2);
StreamEventFactory streamEventFactory = new StreamEventFactory(0, 0, 3);
ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter, streamEventFactory);
streamEventChunk.convertAndAssign(streamEvent1);
streamEventChunk.remove();
streamEventChunk.remove();
}
use of io.siddhi.core.event.stream.converter.ConversionStreamEventChunk in project siddhi by wso2.
the class ComplexEventChunkTestCase method eventChunkRemoveTest4.
@Test
public void eventChunkRemoveTest4() {
StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
streamEvent1.setOutputData(new Object[] { "IBM", 700L, 100L });
StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
streamEvent2.setOutputData(new Object[] { "WSO2", 700L, 100L });
StreamEvent streamEvent3 = new StreamEvent(0, 0, 3);
streamEvent3.setOutputData(new Object[] { "WSO2", 700L, 100L });
StreamEvent streamEvent4 = new StreamEvent(0, 0, 3);
streamEvent4.setOutputData(new Object[] { "WSO2", 700L, 100L });
streamEvent1.setNext(streamEvent2);
streamEvent2.setNext(streamEvent3);
streamEvent3.setNext(streamEvent4);
StreamEventFactory streamEventFactory = new StreamEventFactory(0, 0, 3);
ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter, streamEventFactory);
streamEventChunk.convertAndAssign(streamEvent1);
while (streamEventChunk.hasNext()) {
count++;
streamEventChunk.next();
if (count == 2 || count == 4) {
streamEventChunk.remove();
}
}
StreamEvent streamEvent = streamEventChunk.getFirst();
AssertJUnit.assertEquals(streamEvent1, streamEvent);
AssertJUnit.assertEquals(streamEvent3, streamEvent.getNext());
AssertJUnit.assertNull(streamEvent.getNext().getNext());
}
use of io.siddhi.core.event.stream.converter.ConversionStreamEventChunk in project siddhi by wso2.
the class ComplexEventChunkTestCase method eventChunkRemoveTest3.
@Test
public void eventChunkRemoveTest3() {
StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
streamEvent1.setOutputData(new Object[] { "IBM", 700L, 100L });
StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
streamEvent2.setOutputData(new Object[] { "WSO2", 700L, 100L });
StreamEvent streamEvent3 = new StreamEvent(0, 0, 3);
streamEvent3.setOutputData(new Object[] { "WSO2", 700L, 100L });
StreamEvent streamEvent4 = new StreamEvent(0, 0, 3);
streamEvent4.setOutputData(new Object[] { "WSO2", 700L, 100L });
streamEvent1.setNext(streamEvent2);
streamEvent2.setNext(streamEvent3);
streamEvent3.setNext(streamEvent4);
StreamEventFactory streamEventFactory = new StreamEventFactory(0, 0, 3);
ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter, streamEventFactory);
streamEventChunk.convertAndAssign(streamEvent1);
while (streamEventChunk.hasNext()) {
streamEventChunk.next();
streamEventChunk.remove();
}
AssertJUnit.assertNull(streamEventChunk.getFirst());
}
Aggregations