Пример #1
0
  private void assertModule(
      Module module,
      String name,
      String usesCSV,
      String importsCSV,
      String[] statementsExpected,
      boolean[] commentsExpected,
      int[] lineNumsExpected,
      int[] charStartsExpected,
      int[] charEndsExpected) {
    assertEquals(name, module.getName());

    String[] expectedUses = usesCSV == null ? new String[0] : usesCSV.split(",");
    EPAssertionUtil.assertEqualsExactOrder(expectedUses, module.getUses().toArray());

    String[] expectedImports = importsCSV == null ? new String[0] : importsCSV.split(",");
    EPAssertionUtil.assertEqualsExactOrder(expectedImports, module.getImports().toArray());

    String[] stmtsFound = new String[module.getItems().size()];
    boolean[] comments = new boolean[module.getItems().size()];
    int[] lineNumsFound = new int[module.getItems().size()];
    int[] charStartsFound = new int[module.getItems().size()];
    int[] charEndsFound = new int[module.getItems().size()];

    for (int i = 0; i < module.getItems().size(); i++) {
      stmtsFound[i] = module.getItems().get(i).getExpression();
      comments[i] = module.getItems().get(i).isCommentOnly();
      lineNumsFound[i] = module.getItems().get(i).getLineNumber();
      charStartsFound[i] = module.getItems().get(i).getCharPosStart();
      charEndsFound[i] = module.getItems().get(i).getCharPosEnd();
    }

    EPAssertionUtil.assertEqualsExactOrder(statementsExpected, stmtsFound);
    EPAssertionUtil.assertEqualsExactOrder(commentsExpected, comments);

    boolean isCompareLineNums = false;
    for (int l : lineNumsExpected) {
      if (l > 0) {
        isCompareLineNums = true;
      }
    }
    if (isCompareLineNums) {
      EPAssertionUtil.assertEqualsExactOrder(lineNumsExpected, lineNumsFound);
      EPAssertionUtil.assertEqualsExactOrder(charStartsExpected, charStartsFound);
      EPAssertionUtil.assertEqualsExactOrder(charEndsExpected, charEndsFound);
    }
  }