@Test public void testLoadDbModel() { final DBDatabase db = parser.loadDbModel(); final DBTable departments = db.getTable("DEPARTMENTS"); final DBTable employees = db.getTable("EMPLOYEES"); assertNotNull("Expected DEPARTMENTS table.", departments); assertNotNull("Expected EMPLOYEES table.", employees); final List<DBRelation> relations = db.getRelations(); assertEquals("Should have two relations.", 2, relations.size()); final DBRelation dbRelation = relations.get(1); assertEquals("EMPLOYEES_DEPARTMENT_I_FK", dbRelation.getName()); final DBReference[] references = dbRelation.getReferences(); assertEquals("Should reference one column.", 1, references.length); final DBReference dbReference = references[0]; assertEquals(dbReference.getSourceColumn(), employees.getColumn("DEPARTMENT_ID")); assertEquals(dbReference.getTargetColumn(), departments.getColumn("DEPARTMENT_ID")); final DBColumn salary = employees.getColumn("SALARY"); assertThat(salary.getDataType(), is(DECIMAL)); assertThat(salary.getSize(), is(121.212)); }
public DBDatabase loadDbModel() { DBDatabase db = new InMemoryDatabase(); try { con = openJDBCConnection(config); populateDatabase(db); } catch (SQLException e) { throw new RuntimeException("Unable to read database metadata: " + e.getMessage(), e); } finally { DBUtil.close(con, log); } return db; }
CodeGenParser { public DBDatabase loadDbModel() { DBDatabase db = new InMemoryDatabase(); try { con = openJDBCConnection(config); populateDatabase(db); } catch (SQLException e) { throw new RuntimeException("Unable to read database metadata: " + e.getMessage(), e); } finally { DBUtil.close(con, log); } return db; } }
CodeGenParser { public DBDatabase loadDbModel() { DBDatabase db = new InMemoryDatabase(); try { con = openJDBCConnection(config); populateDatabase(db); } catch (SQLException e) { throw new RuntimeException("Unable to read database metadata: " + e.getMessage(), e); } finally { DBUtil.close(con, log); } return db; } CodeGenParser(CodeGenConfig config); }
CodeGenParser { public DBDatabase loadDbModel() { DBDatabase db = new InMemoryDatabase(); try { con = openJDBCConnection(config); populateDatabase(db); } catch (SQLException e) { throw new RuntimeException("Unable to read database metadata: " + e.getMessage(), e); } finally { DBUtil.close(con, log); } return db; } CodeGenParser(CodeGenConfig config); DBDatabase loadDbModel(); }
CodeGenParser { public DBDatabase loadDbModel() { DBDatabase db = new InMemoryDatabase(); try { con = openJDBCConnection(config); populateDatabase(db); } catch (SQLException e) { throw new RuntimeException("Unable to read database metadata: " + e.getMessage(), e); } finally { DBUtil.close(con, log); } return db; } CodeGenParser(CodeGenConfig config); DBDatabase loadDbModel();  }