use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.
the class BaseTest method run.
public IRuntimeContext run(String actionPath) {
assertTrue(initOk);
SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
return run(actionPath, parameterProvider);
}
use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.
the class SimpleParameterProviderTest method testDates.
public void testDates() throws Exception {
SimpleParameterProvider params = new SimpleParameterProvider();
String dateStr = DateFormat.getInstance().format(new Date());
Date now = DateFormat.getInstance().parse(dateStr);
params.setParameter("date", now);
params.setParameter("date2", dateStr);
assertEquals("wrong date", now, params.getDateParameter("date", null));
assertEquals("wrong date", now, params.getDateParameter("bogus", now));
assertEquals("wrong date", now, params.getDateParameter("date2", null));
assertNull("wrong date", params.getDateParameter("bogus", null));
}
use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.
the class SimpleParameterProviderTest method testAdditional.
public void testAdditional() {
String paramStr = "base?int=100&long=200";
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("_PENTAHO_ADDITIONAL_PARAMS_", paramStr);
SimpleParameterProvider params = new SimpleParameterProvider();
params.copyAndConvertAdditionalParameters(paramMap);
assertEquals("param value is wrong", "100", params.getStringParameter("int", null));
assertEquals("param value is wrong", 100, params.getLongParameter("int", -1));
assertEquals("param value is wrong", "200", params.getStringParameter("long", null));
assertEquals("param value is wrong", 200, params.getLongParameter("long", -1));
paramStr = "int=300&long=400";
paramMap.put("_PENTAHO_ADDITIONAL_PARAMS_", paramStr);
params = new SimpleParameterProvider();
params.copyAndConvertAdditionalParameters(paramMap);
assertEquals("param value is wrong", "300", params.getStringParameter("int", null));
assertEquals("param value is wrong", 300, params.getLongParameter("int", -1));
assertEquals("param value is wrong", "400", params.getStringParameter("long", null));
assertEquals("param value is wrong", 400, params.getLongParameter("long", -1));
}
use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.
the class SimpleParameterProviderTest method testResultSet.
public void testResultSet() {
MemoryResultSet data = new MemoryResultSet();
SimpleParameterProvider params = new SimpleParameterProvider();
params.setParameter("data", data);
assertTrue(params.hasParameter("data"));
assertEquals("param value is wrong", data, params.getListParameter("data"));
}
use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.
the class SimpleParameterProviderTest method testStrings.
public void testStrings() {
SimpleParameterProvider params = new SimpleParameterProvider();
params.setParameter("int", "100");
assertEquals("param value is wrong", "100", params.getParameter("int"));
assertEquals("param value is wrong", "100", params.getStringParameter("int", null));
assertEquals("param value is wrong", 100, params.getLongParameter("int", 0));
BigDecimal decimal = params.getDecimalParameter("int", null);
assertNotNull("param value is wrong", decimal);
assertEquals("param value is wrong", 100, decimal.intValue());
String[] strs = params.getStringArrayParameter("int", new String[0]);
assertNotNull("param value is wrong", strs);
assertEquals("param value is wrong", "100", strs[0]);
}
Aggregations