Search in sources :

Example 16 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class TemplateIT method testTemplate3.

public void testTemplate3() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$
    parameterProvider.setParameter("type", "html");
    // $NON-NLS-1$ //$NON-NLS-2$
    OutputStream outputStream = getOutputStream("TemplateTest.testTemplate3", ".svg");
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
    StandaloneSession session = // $NON-NLS-1$
    new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
    IRuntimeContext context = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    run("/test/template/europemap.xaction", null, false, parameterProvider, outputHandler, session);
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    // $NON-NLS-1$ //$NON-NLS-2$
    assertNotNull("", context.getOutputParameter("svg"));
    finishTest();
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) OutputStream(java.io.OutputStream) SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 17 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class TemplateIT method testTemplate2.

public void testTemplate2() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    IRuntimeContext context = run("/test/template/template2.xaction", parameterProvider);
    assertEquals(Messages.getInstance().getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, // $NON-NLS-1$
    context.getStatus());
    // $NON-NLS-1$ //$NON-NLS-2$
    assertNotNull("", context.getOutputParameter("output"));
    assertEquals("", "Eastern is 120000 with a color of #00ff00, Western is 90000 with a color of #ffff00, Southern is 75000 with a color of #ff0000", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    context.getOutputParameter("output").getStringValue());
    finishTest();
}
Also used : IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 18 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class FilterDefinitionIT method setGlobalParams.

private void setGlobalParams() {
    IPentahoResultSet rs = getFakeResultSet();
    SimpleParameterProvider spp = (SimpleParameterProvider) PentahoSystem.getGlobalParameters();
    // $NON-NLS-1$
    spp.setParameter("customerNamesList", rs);
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 19 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class SimpleParameterProviderTest method testConstructors.

public void testConstructors() {
    SimpleParameterProvider params = new SimpleParameterProvider();
    params.setParameter("param", "value");
    assertEquals("param value if wrong", "value", params.getStringParameter("param", null));
    Map map = new HashMap();
    map.put("param2", "value2");
    params = new SimpleParameterProvider(map);
    assertEquals("param value if wrong", "value2", params.getStringParameter("param2", null));
    assertTrue(params.hasParameter("param2"));
    assertFalse(params.hasParameter("bogus"));
    params = new SimpleParameterProvider(null);
    assertEquals("param value if wrong", null, params.getStringParameter("param2", null));
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 20 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class SimpleParameterProviderTest method testArrays.

public void testArrays() {
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("int-1", new Object[] { new Integer(100) });
    paramMap.put("int-2", new Object[] { new Integer(100), new Integer(999) });
    SimpleParameterProvider params = new SimpleParameterProvider();
    params.copyAndConvertParameters(paramMap);
    assertEquals("param value is wrong", "100", params.getStringParameter("int-1", null));
    assertEquals("param value is wrong", 100, params.getLongParameter("int-1", -1));
    assertEquals("param value is wrong", "100", params.getStringParameter("int-2", null));
    assertEquals("param value is wrong", 100, params.getLongParameter("int-2", -1));
    assertEquals("param value is wrong", -1, params.getLongParameter("int-3", -1));
    Object[] val = params.getArrayParameter("int-2", null);
    assertNotNull("param value is wrong", val);
    assertEquals("param value is wrong", 100, val[0]);
    assertEquals("param value is wrong", 999, val[1]);
    Object[][] value2 = new Object[0][0];
    params.setParameter("2darray", value2);
    assertEquals("param value is wrong", value2, params.getParameter("2darray"));
    assertEquals("param value is wrong", null, params.getStringParameter("2darray", null));
}
Also used : HashMap(java.util.HashMap) 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