예제 #1
0
  public void testGetTableColumns() throws Exception {
    MutableTable table1 = new MutableTable("table1");
    MutableColumn column1 = new MutableColumn("c1", ColumnType.BIGINT);
    MutableColumn column2 = new MutableColumn("c2", ColumnType.BIGINT);
    MutableColumn column3 = new MutableColumn("c3", ColumnType.BIGINT);
    table1.addColumn(column1);
    column1.setTable(table1);
    table1.addColumn(column2);
    column2.setTable(table1);
    table1.addColumn(column3);
    column3.setTable(table1);

    ArrayList<Column> columnList = new ArrayList<Column>();

    Column[] columns = MetaModelHelper.getTableColumns(table1, columnList);
    assertEquals(0, columns.length);

    columnList.add(column1);
    columnList.add(column3);

    columns = MetaModelHelper.getTableColumns(table1, columnList);
    assertEquals(2, columns.length);
    assertSame(column1, columns[0]);
    assertSame(column3, columns[1]);
  }
예제 #2
0
  public void testGetTables() throws Exception {
    MutableTable table1 = new MutableTable("table1");
    MutableTable table2 = new MutableTable("table2");
    MutableColumn t1column1 = new MutableColumn("t1c1", ColumnType.BIGINT);
    MutableColumn t2column1 = new MutableColumn("t2c1", ColumnType.BIGINT);
    MutableColumn t2column2 = new MutableColumn("t2c2", ColumnType.BIGINT);
    table1.addColumn(t1column1);
    t1column1.setTable(table1);
    table2.addColumn(t2column1);
    t2column1.setTable(table2);
    table2.addColumn(t2column2);
    t2column2.setTable(table2);

    ArrayList<Table> tableList = new ArrayList<Table>();
    tableList.add(table1);

    ArrayList<Column> columnList = new ArrayList<Column>();
    columnList.add(t2column1);

    Table[] tables = MetaModelHelper.getTables(tableList, columnList);
    assertEquals(2, tables.length);
    assertTrue(Arrays.asList(tables).contains(table1));
    assertTrue(Arrays.asList(tables).contains(table2));
  }