use of org.teiid.translator.simpledb.SimpleDBInsertVisitor in project teiid by teiid.
the class TestSimpleDBExecution method testInsert.
@Test
public void testInsert() throws Exception {
String query = "insert into item (\"itemName()\", attribute, somedate, strarray) values ('one', 'value', {ts '2014-04-04 10:50:45'}, ('1', '2'))";
Command cmd = utility.parseCommand(query);
ExecutionContext context = Mockito.mock(ExecutionContext.class);
UpdateExecution exec = translator.createUpdateExecution(cmd, context, Mockito.mock(RuntimeMetadata.class), connection);
exec.execute();
SimpleDBInsertVisitor visitor = new SimpleDBInsertVisitor();
visitor.visitNode(cmd);
ArgumentCaptor<Iterator> argument = ArgumentCaptor.forClass(Iterator.class);
ArgumentCaptor<String> itemName = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<ArrayList> columns = ArgumentCaptor.forClass(ArrayList.class);
Mockito.verify(connection).performInsert(itemName.capture(), columns.capture(), argument.capture());
assertEquals("item", itemName.getValue());
List<?> values = (List<?>) argument.getValue().next();
assertEquals("value", values.get(1));
assertEquals("2014-04-04 10:50:45.0", values.get(2).toString());
assertEquals("1,2,", arrayToStr((String[]) values.get(3)));
}
Aggregations