Exemple #1
0
 /**
  * Get Instructions from the assertions; NOOP's are filtered out.
  *
  * @param assertions
  * @return
  */
 public static List<Instruction> getInstructions(List<Assertion> assertions) {
   List<Instruction> instructions = new ArrayList<Instruction>(assertions.size());
   for (Assertion a : assertions) {
     if (a.getInstruction() != Instruction.NOOP_INSTRUCTION) {
       instructions.add(a.getInstruction());
     }
   }
   return instructions;
 }
 @Override
 public List<Assertion> getAssertions() throws SyntaxError {
   if (table.getRowCount() < 2) throw new SyntaxError("Query tables must have at least two rows.");
   assignColumns();
   Assertion make = constructFixture(getFixtureName());
   Assertion ti =
       makeAssertion(
           callFunction(getTableName(), "table", tableAsList()),
           new SilentReturnExpectation(0, 0));
   Assertion qi =
       makeAssertion(callFunction(getTableName(), "query"), new QueryTableExpectation());
   tableInstruction = ti.getInstruction().getId();
   queryId = qi.getInstruction().getId();
   // addExpectation(new QueryTableExpectation());
   return list(make, ti, qi);
 }
 private void assertTableResults(String tableRows, List<Object> tableResults, String table)
     throws Exception {
   makeTableTableAndBuildInstructions(tableTableHeader + tableRows);
   Map<String, Object> pseudoResults =
       SlimClient.resultToMap(
           list(list("tableTable_id_0", "OK"), list("tableTable_id_1", tableResults)));
   Assertion.evaluateExpectations(assertions, pseudoResults);
   assertEquals(table, tt.getTable().toString());
 }
 @Test
 public void tableMethodThrowsException() throws Exception {
   makeTableTableAndBuildInstructions(tableTableHeader + "|2|4|\n");
   Map<String, Object> pseudoResults =
       SlimClient.resultToMap(
           list(list("tableTable_id_0", "OK"), list("tableTable_id_1", "Exception: except")));
   Assertion.evaluateExpectations(assertions, pseudoResults);
   assertEquals("[[error(Exception: except), argument], [2, 4]]", tt.getTable().toString());
 }
 @Test
 public void tableWithSymbols() throws Exception {
   makeTableTableAndBuildInstructions(tableTableHeader + "|$X|$X|\n");
   tt.setSymbol("X", "value");
   Map<String, Object> pseudoResults =
       SlimClient.resultToMap(
           list(
               list("tableTable_id_0", "OK"),
               list("tableTable_id_1", list(list("pass", "fail")))));
   Assertion.evaluateExpectations(assertions, pseudoResults);
   assertEquals(
       "[[pass(Table:fixture), argument], [pass($X->[value]), fail($X->[value])]]",
       tt.getTable().toString());
 }
 private List<Instruction> instructions() {
   return Assertion.getInstructions(assertions);
 }
Exemple #7
0
 public static void evaluateExpectations(List<Assertion> assertions, Map<String, Object> results) {
   for (Assertion a : assertions) {
     Object returnValue = results.get(a.getInstruction().getId());
     a.getExpectation().evaluateExpectation(returnValue);
   }
 }