public void assertFalse(String objectLocalization) {
   Boolean b = getObject(Boolean.class, objectLocalization, false);
   if (b == null) {
     Assert.fail(csvRunner.getAssertionErrorMessagePrefix() + "null Boolean");
   } else {
     Assert.assertFalse(
         csvRunner.getAssertionErrorMessagePrefix() + "FALSE expected", b.booleanValue());
   }
 }
 /**
  * @param value
  * @param objectLocalization
  */
 public void assertNumberExact(String value, String objectLocalization) {
   Integer i = getObject(Integer.class, objectLocalization, false);
   if (i != null) {
     Assert.assertEquals(
         csvRunner.getAssertionErrorMessagePrefix() + "Wrong number",
         Integer.parseInt(value),
         i.intValue());
   } else {
     Long l = getObject(Long.class, objectLocalization);
     Assert.assertEquals(
         csvRunner.getAssertionErrorMessagePrefix() + "Wrong number",
         Long.parseLong(value),
         l.intValue());
   }
 }
 protected void checkWidgetVisibleAndEnable(FocusWidget widget, String objectLocalization) {
   Assert.assertTrue(
       csvRunner.getAssertionErrorMessagePrefix()
           + "Widget have to be enabled : "
           + objectLocalization,
       widget.isEnabled());
   checkWidgetVisible(widget, objectLocalization);
 }
 protected void checkWidgetVisible(Widget widget, String objectLocalization) {
   Assert.assertTrue(
       csvRunner.getAssertionErrorMessagePrefix()
           + "Widget have to be visible : "
           + objectLocalization
           + ", "
           + widget.getClass().getCanonicalName(),
       WidgetUtils.isWidgetVisible(widget));
 }
  @SuppressWarnings("unchecked")
  protected final <T> T getObject(Class<T> clazz, String objectLocalization, boolean failOnError) {
    Node n = Node.parse(objectLocalization);
    Assert.assertNotNull(
        csvRunner.getAssertionErrorMessagePrefix() + "Unable to parse " + objectLocalization, n);
    Assert.assertNotNull(
        csvRunner.getAssertionErrorMessagePrefix() + "Localization must have two /", n.getNext());
    String prefix = n.getLabel();
    Node next = n.getNext();
    PrefixProcessor processor = findPrefixProcessor(prefix);
    Assert.assertNotNull(
        csvRunner.getAssertionErrorMessagePrefix() + "Unkown prefix : <" + prefix + ">", processor);
    Object o = processor.process(csvRunner, next, failOnError);
    if (clazz.isInstance(o)) {
      return (T) o;
    }
    if (!failOnError) {
      return null;
    }

    if (o == null) {
      Assert.fail(
          csvRunner.getAssertionErrorMessagePrefix()
              + "Targeted object ["
              + objectLocalization
              + "] is null");
    }

    Assert.fail(
        csvRunner.getAssertionErrorMessagePrefix()
            + "Wrong object type, not a "
            + clazz.getCanonicalName()
            + " : "
            + o.getClass().getCanonicalName());
    return null;
  }
  public void runMacro(String macroName, String... params) throws Exception {
    List<List<String>> macro = macroReader.getMacro(macroName);
    Assert.assertNotNull(
        csvRunner.getAssertionErrorMessagePrefix() + "Not existing macro " + macroName, macro);
    int i = 0;
    for (List<String> line : macro) {
      List<String> l = new ArrayList<String>();
      for (String s : line) {
        String replaced = s;
        for (int z = 0; z < params.length; z++) {
          String param = params[z];
          if (param == null) param = "*null*";
          else if ("".equals(param)) param = "*empty*";

          replaced = replaced.replaceAll("\\{" + z + "\\}", param);
        }
        l.add(replaced);
      }
      csvRunner.setExtendedLineInfo(macroName + " line " + (i + 1));
      csvRunner.executeRow(l, this);
      i++;
    }
    csvRunner.setExtendedLineInfo(null);
  }
 public void assertInstanceOf(String className, String objectLocalisation) {
   try {
     Class<?> clazz = Class.forName(className);
     Object o = getObject(Object.class, objectLocalisation);
     Assert.assertTrue(
         csvRunner.getAssertionErrorMessagePrefix()
             + "Target object is not an instance of ["
             + className
             + "] but an instance of ["
             + o.getClass().getCanonicalName()
             + "]",
         clazz.isAssignableFrom(o.getClass()));
   } catch (ClassNotFoundException e) {
     Assert.fail(
         "Cannot assert instance of [" + className + "] because the class cannot be found");
   }
 }
 public void isNotEnabled(String objectLocalization) {
   FocusWidget button = getFocusWidget(objectLocalization);
   Assert.assertFalse(
       csvRunner.getAssertionErrorMessagePrefix() + "is Enabled " + objectLocalization,
       button.isEnabled());
 }
 public void isNotVisible(String objectLocalization) {
   Widget widget = getObject(Widget.class, objectLocalization);
   Assert.assertFalse(
       csvRunner.getAssertionErrorMessagePrefix() + "Visible " + objectLocalization,
       widget.isVisible());
 }
 public void isNotChecked(String objectLocalization) {
   CheckBox checkBox = getObject(CheckBox.class, objectLocalization);
   Assert.assertTrue(
       csvRunner.getAssertionErrorMessagePrefix() + "Checkbox checked", !checkBox.getValue());
 }
 public void assertNotExist(String objectLocalization) {
   Object o = getObject(Object.class, objectLocalization, false);
   Assert.assertNull(csvRunner.getAssertionErrorMessagePrefix() + "Object exist", o);
 }
 public void clickPanel(String objectLocalization) {
   FocusPanel widget = getObject(FocusPanel.class, objectLocalization);
   checkWidgetVisibleAndEnable(widget, objectLocalization);
   WidgetUtils.click(widget, csvRunner.getAssertionErrorMessagePrefix(), objectLocalization);
 }
 /**
  * Launch a JavaScript "onClick" event on the target object.
  *
  * @param objectLocalization The targeted object localisation path.
  */
 public void click(String objectLocalization) {
   Widget widget = getObject(Widget.class, objectLocalization);
   WidgetUtils.click(widget, csvRunner.getAssertionErrorMessagePrefix(), objectLocalization);
 }
 /**
  * @param value
  * @param objectLocalization
  */
 public void assertContains(String value, String objectLocalization) {
   String s = getObject(String.class, objectLocalization);
   Assert.assertTrue(
       csvRunner.getAssertionErrorMessagePrefix() + " not containing string " + value,
       s.contains(value));
 }
 /**
  * @param value
  * @param objectLocalization
  */
 public void assertExact(String value, String objectLocalization) {
   String s = getObject(String.class, objectLocalization, false);
   Assert.assertEquals(csvRunner.getAssertionErrorMessagePrefix() + "Wrong string", value, s);
 }
 public void hasStyle(String style, String objectLocalization) {
   Widget w = getObject(Widget.class, objectLocalization);
   Assert.assertTrue(
       csvRunner.getAssertionErrorMessagePrefix() + "Style not found : " + style,
       w.getStyleName().contains(style));
 }
 public void launchTest(String testName) throws Exception {
   csvRunner.runSheet(reader.getTest(testName), this);
 }