Exemplo n.º 1
0
  @Test
  public void testStringStringFunction() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "StringFunction");
    fi.reset();
    fi.insertOperand("indexOf");
    fi.insertOperand("Apenoot");
    fi.insertOperand("n");

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(Integer.class, o.getClass());

    fi.reset();
    fi.insertOperand("substring");
    fi.insertOperand("Apenoot");
    fi.insertOperand(new Integer(0));
    fi.insertOperand(new Integer(4));

    o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(String.class, o.getClass());
  }
Exemplo n.º 2
0
  @Test
  public void testSize() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "Size");
    fi.reset();
    fi.insertOperand("NOOT");

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(Integer.class, o.getClass());
    assertEquals("4", o.toString());

    fi.reset();
    fi.insertOperand(createTestNavajo().getMessage("Aap"));

    o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(Integer.class, o.getClass());
    assertEquals("1", o.toString());

    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(new Integer(10));
    list.add(new Integer(10));
    fi.reset();
    fi.insertOperand(list);

    o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(Integer.class, o.getClass());
    assertEquals("2", o.toString());
  }
Exemplo n.º 3
0
  @Test
  public void testDateField() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "DateField");
    fi.reset();
    fi.insertOperand(new java.util.Date());
    fi.insertOperand("YEAR");

    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(Integer.class, o.getClass());
  }
Exemplo n.º 4
0
  @Test
  public void testZip() throws Exception {

    Binary b = new Binary(new byte[] {1, 1, 1});
    FunctionInterface fi = fff.getInstance(cl, "Zip");
    fi.reset();
    fi.insertOperand(b);
    fi.insertOperand("aap");
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(o.getClass(), Binary.class);
  }
Exemplo n.º 5
0
  @Test
  public void testStringDistance() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "StringDistance");
    fi.reset();
    fi.insertOperand("AAP");
    fi.insertOperand("NOOT");

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(Integer.class, o.getClass());
  }
Exemplo n.º 6
0
  @Test
  public void testScaleImageFree() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "ScaleImageFree");
    fi.reset();
    fi.insertOperand(null);
    fi.insertOperand(10);
    fi.insertOperand(10);

    Object o = fi.evaluateWithTypeChecking();

    assertNull(o);
  }
Exemplo n.º 7
0
  @Test
  public void testCheckUniqueness() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "CheckUniqueness");
    fi.reset();
    fi.setInMessage(createTestNavajo());
    fi.insertOperand("Aap");
    fi.insertOperand("Noot");

    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(Boolean.class, o.getClass());
  }
Exemplo n.º 8
0
  @Test
  public void testEqualsPattern() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "EqualsPattern");
    fi.reset();
    fi.insertOperand("apenoot");
    fi.insertOperand("[A-z]*");

    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(Boolean.class, o.getClass());
    assertEquals("true", o.toString());
  }
Exemplo n.º 9
0
  @Test
  public void testExists() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "Exists");
    fi.reset();
    fi.setInMessage(createTestNavajo());
    fi.insertOperand(createTestNavajo().getMessage("Aap"));
    fi.insertOperand("true");

    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals("true", o.toString());
  }
Exemplo n.º 10
0
  @Test
  public void testForAll() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "ForAll");
    fi.reset();
    fi.setInMessage(createTestNavajo());
    fi.insertOperand("/Aap");
    fi.insertOperand("[Noot] != 20");

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
  }
Exemplo n.º 11
0
  @Test
  public void testFormatDate() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "FormatDate");
    fi.reset();

    fi.insertOperand(new java.util.Date());
    fi.insertOperand("yyyy-MM-dd");

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
  }
Exemplo n.º 12
0
  @Test
  public void testRound() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "Round");
    fi.reset();
    fi.insertOperand(new Double(10.5));
    fi.insertOperand(0);

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(Double.class, o.getClass());
  }
Exemplo n.º 13
0
  @Test
  public void testParseStringList() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "ParseStringList");
    fi.reset();
    fi.insertOperand("aap,noot,mies");
    fi.insertOperand(",");

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertTrue(List.class.isInstance(o));
  }
Exemplo n.º 14
0
  @Test
  public void testGetWeekDayDate2() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "GetWeekDayDate");
    fi.reset();
    fi.insertOperand("SUN");
    fi.insertOperand("forward");
    // fi.insertOperand(new java.util.Date());

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(java.util.Date.class, o.getClass());
  }
Exemplo n.º 15
0
  @Test
  public void testGetPropertySubType() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "GetPropertySubType");
    fi.reset();
    fi.setInMessage(createTestNavajo());
    Navajo doc = createTestNavajo();
    fi.insertOperand("/Single/Selectie");
    fi.insertOperand("testsub");

    Object o = fi.evaluateWithTypeChecking();

    assertNull(o);
  }
Exemplo n.º 16
0
  @Test
  public void testInMonthTurnInterval() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "InMonthTurnInterval");
    fi.reset();
    fi.insertOperand(new java.util.Date());
    fi.insertOperand(5);
    fi.insertOperand(true);

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(Boolean.class, o.getClass());
  }
Exemplo n.º 17
0
  @Test
  public void testRandomString2() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "RandomString");
    fi.reset();
    fi.insertOperand(10);
    fi.insertOperand("abcdef");

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(String.class, o.getClass());
    assertEquals(o.toString().indexOf("g"), -1);
  }
Exemplo n.º 18
0
  @Test
  public void testSetAllProperties() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "SetAllProperties");
    fi.reset();
    fi.setInMessage(createTestNavajo());
    fi.insertOperand(createTestNavajo().getMessage("Aap"));
    fi.insertOperand("Noot");
    fi.insertOperand(new Integer(2));

    Object o = fi.evaluateWithTypeChecking();

    assertNull(o);
  }
Exemplo n.º 19
0
  @Test
  public void testStringPadding3() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "StringPadding");
    fi.reset();
    fi.insertOperand("aap");
    fi.insertOperand(new Integer(10));

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(String.class, o.getClass());
    assertEquals("aap       ", o.toString());
  }
Exemplo n.º 20
0
  @Test
  public void testGetMessage() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "GetMessage");
    Navajo doc = createTestNavajo();
    fi.setInMessage(doc);

    fi.reset();
    fi.insertOperand(doc.getMessage("Aap"));
    fi.insertOperand(0);

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
  }
Exemplo n.º 21
0
  @Test
  public void testGetProperty() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "GetProperty");
    fi.reset();
    fi.setInMessage(createTestNavajo());
    Navajo doc = createTestNavajo();
    fi.insertOperand(doc.getMessage("Single"));
    fi.insertOperand("Selectie");

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertTrue(Property.class.isInstance(o));
  }
Exemplo n.º 22
0
  @Test
  public void testSumProperties() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "SumProperties");
    fi.setInMessage(createTestNavajo());

    fi.reset();
    fi.insertOperand("Aap");
    fi.insertOperand("Noot");

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(Integer.class, o.getClass());
    assertEquals("10", o.toString());
  }
Exemplo n.º 23
0
  @Test
  public void testIsServiceCached() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "IsServiceCached");
    fi.reset();
    fi.insertOperand("aap");
    fi.insertOperand("noot");

    try {
      Object o = fi.evaluateWithTypeChecking();

      assertNotNull(o);
    } catch (NullPointerException n) {

    }
  }
Exemplo n.º 24
0
  @Test
  public void testFormatStringList() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "FormatStringList");
    fi.reset();
    ArrayList<String> list = new ArrayList<String>();
    list.add(new String("10"));
    list.add(new String("20"));
    fi.insertOperand(list);
    fi.insertOperand("&");

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals("10&20", o.toString());
  }
Exemplo n.º 25
0
  @Test
  public void testArraySelection() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "ArraySelection");

    fi.reset();
    fi.setInMessage(createTestNavajo());
    fi.insertOperand("Aap");
    fi.insertOperand("Noot");
    fi.insertOperand("10");

    try {
      Object o = fi.evaluateWithTypeChecking();
    } catch (Exception e) {
    }
  }
Exemplo n.º 26
0
  @Test
  public void testToMilliseconds() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "ToMilliseconds");
    fi.reset();
    fi.insertOperand(new StopwatchTime(20));
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(Integer.class, o.getClass());

    fi.reset();
    fi.insertOperand(new ClockTime(new java.util.Date()));
    o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
    assertEquals(Long.class, o.getClass());
  }
Exemplo n.º 27
0
  @Test
  public void testAbs() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "Abs");

    // Test Integer.
    fi.reset();
    fi.insertOperand(new Integer(-10));
    Object o = fi.evaluateWithTypeChecking();
    assertEquals(o.getClass(), Integer.class);
    assertEquals(((Integer) o).intValue(), 10);

    // Test Double.
    fi.reset();
    fi.insertOperand(new Double(-10));
    o = fi.evaluateWithTypeChecking();
    assertEquals(o.getClass(), Double.class);
    assertEquals(((Double) o).intValue(), 10);

    // Test bogus.
    boolean bogus = false;
    fi.reset();
    fi.insertOperand(new String("-10"));
    try {
      o = fi.evaluateWithTypeChecking();
    } catch (TMLExpressionException e) {
      bogus = true;
    }
    assertTrue(bogus);

    // Test null.
    fi.reset();
    fi.insertOperand(null);
    o = fi.evaluateWithTypeChecking();
    assertNull(o);

    // Test empty parameters.
    boolean empty = false;
    fi.reset();
    try {
      o = fi.evaluateWithTypeChecking();
    } catch (TMLExpressionException e) {
      empty = true;
    }
    assertTrue(empty);
  }
Exemplo n.º 28
0
  @Test
  public void testTrunc() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "Trunc");
    fi.reset();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    Date d1 = sdf.parse("2009-12-01 12:34");
    Date d2 = sdf.parse("2009-12-01 14:54");
    fi.insertOperand(d1);
    Date d3 = (Date) fi.evaluate();

    fi.reset();
    fi.insertOperand(d2);
    Date d4 = (Date) fi.evaluate();

    assertEquals(sdf.format(d3), sdf.format(d4));
  }
Exemplo n.º 29
0
  @Test
  public void testOffsetDate() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "OffsetDate");
    fi.reset();
    fi.insertOperand(new java.util.Date());
    fi.insertOperand(10);
    fi.insertOperand(6);
    fi.insertOperand(17);
    fi.insertOperand(12);
    fi.insertOperand(0);
    fi.insertOperand(0);

    Object o = fi.evaluateWithTypeChecking();

    assertNotNull(o);
    assertEquals(java.util.Date.class, o.getClass());
  }
Exemplo n.º 30
0
  @Test
  public void testUnicode() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "Unicode");
    fi.reset();
    fi.insertOperand("10");
    Object o = fi.evaluateWithTypeChecking();
    assertNotNull(o);
  }