|
|
|
@ -14,6 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
public class BaseFunctionTest { |
|
|
|
|
protected static final String NUMBER_SERIES = "{\"empty\": [], \"numbers\" : [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}"; |
|
|
|
|
protected static final String TEXT_SERIES = "{\"urls\": [\"http://api.worldbank.org/countries/all/?format=json\", \"http://api.worldbank.org/countries/all/?format=json\"], \"text\" : [ \"a\", \"b\", \"c\", \"d\", \"e\", \"f\" ]}"; |
|
|
|
|
protected static final String TEXT_AND_NUMBER_SERIES = "{\"text\" : [ \"a\", \"b\", \"c\", \"d\", \"e\", \"f\" ], \"numbers\" : [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Verify the function returns the correct result based on the input expectedValue |
|
|
|
@ -40,6 +41,10 @@ public class BaseFunctionTest {
|
|
|
|
|
verifyFunction(conf, pathExpr, TEXT_SERIES, expectedValue); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void verifyTextAndNumberFunction(Configuration conf, String pathExpr, Object expectedValue) { |
|
|
|
|
verifyFunction(conf, pathExpr, TEXT_AND_NUMBER_SERIES, expectedValue); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected String getResourceAsText(String resourceName) throws IOException { |
|
|
|
|
return new Scanner(BaseFunctionTest.class.getResourceAsStream(resourceName), "UTF-8").useDelimiter("\\A").next(); |
|
|
|
|
} |
|
|
|
|