SiddhiUtils { public static Object[] getOrderedValues(StreamDefinition streamMetaData, List<ColumnNameTypeValue> columns) throws AttributeNotExistException { Object[] orderedValues = new Object[streamMetaData.getAttributeList().size()]; for (ColumnNameTypeValue column : columns) { if (column.getValue() instanceof String) { orderedValues[streamMetaData.getAttributePosition(column.getColumn())] = decodeSiddhiValue( (String) column.getValue(), streamMetaData.getAttributeType(column.getColumn())); } else if (column.getValue() instanceof Double) { orderedValues[streamMetaData.getAttributePosition(column.getColumn())] = decodeSiddhiValue( (Double) column.getValue(), streamMetaData.getAttributeType(column.getColumn())); } else { orderedValues[streamMetaData.getAttributePosition(column.getColumn())] = column.getValue(); } } return orderedValues; } private  SiddhiUtils(); static boolean columnAlreadyExistsInStream(String columnName, StreamDefinition streamMetaData); static Object[] getOrderedValues(StreamDefinition streamMetaData, List<ColumnNameTypeValue> columns); static Boolean isStreamAllowedForThisOperation(String streamName, String operation); static final String QUERY_PLAN_IDENTIFIER; }
@Test public void testGetOrderedValues() throws Exception { List<ColumnNameTypeValue> columns = new ArrayList<>(); columns.add(new ColumnNameTypeValue("myAttr", ColumnType.STRING, "test")); columns.add(new ColumnNameTypeValue("myAttr2", ColumnType.BOOLEAN, true)); columns.add(new ColumnNameTypeValue("myAttr3", ColumnType.DOUBLE, 3.1)); StreamDefinition definition= Mockito.mock(StreamDefinition.class); when(definition.getAttributeList()).thenReturn(listAttributes); when(definition.getAttributePosition("myAttr")).thenReturn(0); when(definition.getAttributePosition("myAttr2")).thenReturn(1); when(definition.getAttributePosition("myAttr3")).thenReturn(2); doReturn(Attribute.Type.STRING).when(definition).getAttributeType("myAttr"); doReturn(Attribute.Type.BOOL).when(definition).getAttributeType("myAttr2"); doReturn(Attribute.Type.DOUBLE).when(definition).getAttributeType("myAttr3"); Object[] result= SiddhiUtils.getOrderedValues(definition, columns); assertEquals("Unexpected columns size", 6, result.length); }