Search in sources :

Example 51 with SimpleParameterProvider

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);
}
Also used : SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 52 with SimpleParameterProvider

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));
}
Also used : Date(java.util.Date) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 53 with SimpleParameterProvider

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));
}
Also used : HashMap(java.util.HashMap) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 54 with SimpleParameterProvider

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"));
}
Also used : MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 55 with SimpleParameterProvider

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]);
}
Also used : BigDecimal(java.math.BigDecimal) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Aggregations

SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)72 HashMap (java.util.HashMap)32 ArrayList (java.util.ArrayList)23 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)23 OutputStream (java.io.OutputStream)21 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)21 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)21 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)21 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)16 Test (org.junit.Test)13 IOException (java.io.IOException)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 MockHttpServletRequest (com.mockrunner.mock.web.MockHttpServletRequest)7 MockHttpServletResponse (com.mockrunner.mock.web.MockHttpServletResponse)7 Map (java.util.Map)5 IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)5 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)5 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)5 BaseRequestHandler (org.pentaho.platform.engine.services.BaseRequestHandler)5 Iterator (java.util.Iterator)4