1 package net.jaekl.cfb.db;
3 import java.util.ArrayList;
5 import static org.junit.Assert.*;
7 public class TableMock extends Table {
9 private ArrayList<Row> m_rows;
11 public TableMock(String name, Column[] columns) {
13 m_rows = new ArrayList<Row>();
16 public TableMock(Table table) {
17 this(table.m_name, table.m_columns.toArray(new Column[table.m_columns.size()]));
20 protected ArrayList<Row> mock_getRows() { return m_rows; }
22 public boolean mock_hasColumn(Column expectedCol) {
23 for (Column col : m_columns) {
24 if (col.equals(expectedCol)) {
31 public Column[] mock_getColumns() {
32 return m_columns.toArray(new Column[m_columns.size()]);
35 public void mock_insert(Row row) {
36 assertEquals(getNumColumns(), row.getNumColumns());
37 for (int i = 0; i < getNumColumns(); ++i) {
38 assertEquals(getColumn(i).getType(), row.getColumn(i).getType());