コード例 #1
0
 public void handleFormula(
     LogicalModel model,
     LogicalTable table,
     String databaseToTest,
     String mqlFormula,
     String expectedSql) {
   // retrieve various databases here
   DatabaseMeta databaseMeta =
       new DatabaseMeta(
           "",
           databaseToTest,
           "Native",
           "",
           "",
           "",
           "",
           ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
                // //$NON-NLS-7$
   try {
     SqlOpenFormula formula =
         new SqlOpenFormula(model, table, databaseMeta, mqlFormula, null, null, false);
     formula.parseAndValidate();
     String sql = formula.generateSQL("en_US"); // $NON-NLS-1$
     Assert.assertNotNull(sql);
     sql = sql.trim();
     Assert.assertEquals(expectedSql, sql);
   } catch (Exception e) {
     e.printStackTrace();
     Assert.fail();
   }
 }
コード例 #2
0
 public void handleFormulaFailure(
     LogicalModel model,
     String databaseToTest,
     Map<String, Object> params,
     String mqlFormula,
     String expectedException) {
   // retrieve various databases here
   DatabaseMeta databaseMeta =
       new DatabaseMeta(
           "",
           databaseToTest,
           "Native",
           "",
           "",
           "",
           "",
           ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
                // //$NON-NLS-7$
   try {
     SqlOpenFormula formula =
         new SqlOpenFormula(model, databaseMeta, mqlFormula, null, params, false);
     formula.parseAndValidate();
     formula.generateSQL("en_US"); // $NON-NLS-1$
     Assert.fail();
   } catch (Exception e) {
     Assert.assertEquals(e.getMessage(), expectedException);
   }
 }