use of com.twitter.elephantbird.pig.piggybank.InvokeForString in project elephant-bird by twitter.
the class TestInvoker method testArrayConversion.
@Test
public void testArrayConversion() throws SecurityException, ClassNotFoundException, NoSuchMethodException, IOException {
InvokeForInt id = new InvokeForInt(TestInvoker.class.getName() + ".avg", "double[]");
DataBag nums = newSimpleBag(1.0, 2.0, 3.0);
assertEquals(Integer.valueOf(2), id.exec(tf_.newTuple(nums)));
InvokeForString is = new InvokeForString(TestInvoker.class.getName() + ".concatStringArray", "string[]");
DataBag strings = newSimpleBag("foo", "bar", "baz");
assertEquals("foobarbaz", is.exec(tf_.newTuple(strings)));
}
use of com.twitter.elephantbird.pig.piggybank.InvokeForString in project elephant-bird by twitter.
the class TestInvoker method testStringInvoker.
@Test
public void testStringInvoker() throws SecurityException, ClassNotFoundException, NoSuchMethodException, IOException {
// Test non-static method
InvokeForString is = new InvokeForString("java.lang.String.toUpperCase", "String", "false");
assertEquals("FOO", is.exec(tf_.newTuple("foo")));
// both "static" and "true" should work
// Test static method
is = new InvokeForString("java.lang.String.valueOf", "int", "true");
Tuple t = tf_.newTuple(1);
t.set(0, 231);
assertEquals("231", is.exec(t));
// test default (should be static)
is = new InvokeForString("java.lang.String.valueOf", "int");
assertEquals("231", is.exec(t));
// Test method with multiple args
is = new InvokeForString(TestInvoker.class.getName() + ".concatStrings", "String String");
t = tf_.newTuple(2);
t.set(0, "foo");
t.set(1, "bar");
assertEquals("foobar", is.exec(t));
}
Aggregations