use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.
the class ActionSequenceParameterContentGenerator method getRequestParameters.
@SuppressWarnings("unchecked")
private IParameterProvider getRequestParameters() {
if (this.requestParameters != null) {
return this.requestParameters;
}
if (this.parameterProviders == null) {
return new SimpleParameterProvider();
}
// $NON-NLS-1$
IParameterProvider requestParams = this.parameterProviders.get("request");
SimpleParameterSetter parameters = new SimpleParameterSetter();
Iterator requestParamIterator = requestParams.getParameterNames();
while (requestParamIterator.hasNext()) {
String param = (String) requestParamIterator.next();
parameters.setParameter(param, requestParams.getParameter(param));
}
this.requestParameters = parameters;
return parameters;
}
use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.
the class ActionSequenceParameterUiContentGenerator method getRequestParameters.
@SuppressWarnings("unchecked")
private IParameterProvider getRequestParameters() {
if (this.parameterProviders == null) {
return new SimpleParameterProvider();
}
// $NON-NLS-1$
IParameterProvider requestParams = this.parameterProviders.get("request");
SimpleParameterSetter parameters = new SimpleParameterSetter();
Iterator requestParamIterator = requestParams.getParameterNames();
while (requestParamIterator.hasNext()) {
String param = (String) requestParamIterator.next();
parameters.setParameter(param, requestParams.getParameter(param));
}
this.requestParameters = parameters;
return parameters;
}
use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.
the class WsdlPageTest method testBadServiceName.
@Test
public void testBadServiceName() throws Exception {
// $NON-NLS-1$
assertNotNull("Logger is null", contentGenerator.getLogger());
Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
parameterProviders.put(IParameterProvider.SCOPE_REQUEST, new SimpleParameterProvider());
SimpleParameterProvider pathParams = new SimpleParameterProvider();
// $NON-NLS-1$//$NON-NLS-2$
pathParams.setParameter("path", "/bogus");
// $NON-NLS-1$
parameterProviders.put("path", pathParams);
contentGenerator.setParameterProviders(parameterProviders);
contentGenerator.createContent();
String content = new String(out.toByteArray());
assertTrue(content, content.contains(Messages.getInstance().getErrorString("WebServiceContentGenerator.ERROR_0006_SERVICE_IS_INVALID", // $NON-NLS-1$ //$NON-NLS-2$
"bogus")));
}
use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.
the class ChartIT method testChartHelper_Null.
/*
* public void testCategoryAreaChart() { runCategoryChartTest(JFreeChartEngine.AREA_CHART_TYPE,
* "test/charts/areaChart.xml", "testAreaChart"); //$NON-NLS-1$ //$NON-NLS-2$ }
*
* public void testCategoryBarChart() { runCategoryChartTest(JFreeChartEngine.BAR_CHART_TYPE,
* "test/charts/barChart.xml", "testBarChart"); //$NON-NLS-1$ //$NON-NLS-2$ }
*
* public void testCategoryLineChart() { runCategoryChartTest(JFreeChartEngine.LINE_CHART_TYPE,
* "test/charts/lineChart.xml", "testLineChart"); //$NON-NLS-1$ //$NON-NLS-2$ }
*
* public void testPieChart() { runPieChartTest(JFreeChartEngine.PIE_CHART_TYPE, "test/charts/pieChart.xml",
* "testPieChart"); //$NON-NLS-1$ //$NON-NLS-2$ }
*/
/*
* public void testChartHelper_DialChart() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
* ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
* parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
* "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
* parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
* parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter(
* "drill-url", "SampleDashboard.jsp?region=" + region + "&department={DEPARTMENT}&measure={measure}");
* //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parameters.setParameter("series-name", "measure"); //$NON-NLS-1$
* //$NON-NLS-2$ parameters.setParameter("chart-type", "DialChart"); //$NON-NLS-1$ //$NON-NLS-2$
* parameters.setParameter("value", "550"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content = new StringBuffer();
* StandaloneSession session = new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION"));
* //$NON-NLS-1$ ChartHelper.doChart("/test-src/solutions/samples/dashboard/departments.widget.xml", parameters,
* content, session, messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os =
* getOutputStream(SOLUTION_PATH, "ChartTest.testChartHelper_DialChart", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
* os.write(content.toString().getBytes()); } catch (Exception e) {
*
* } }
*
* public void testChartHelper_PieChart() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
* ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
* parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
* "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
* parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
* parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter(
* "drill-url", "SampleDashboard.jsp?region=" + region + "&department={DEPARTMENT}&measure={measure}");
* //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parameters.setParameter("series-name", "measure"); //$NON-NLS-1$
* //$NON-NLS-2$ parameters.setParameter("chart-type", "PieChart"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content =
* new StringBuffer(); StandaloneSession session = new
* StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
* ChartHelper.doChart("/test-src/solutions/samples/dashboard/departments.widget.xml", parameters, content, session,
* messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os = getOutputStream(SOLUTION_PATH,
* "ChartTest.testChartHelper_PieChart", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
* os.write(content.toString().getBytes()); } catch (Exception e) {
*
* } }
*
* public void testChartHelper_PieGrid() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
* ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
* parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
* "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
* parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
* parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter(
* "drill-url", "SampleDashboard.jsp?region=" + region + "&department={DEPARTMENT}&measure={measure}");
* //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parameters.setParameter("series-name", "measure"); //$NON-NLS-1$
* //$NON-NLS-2$ parameters.setParameter("chart-type", "PieGrid"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content =
* new StringBuffer(); StandaloneSession session = new
* StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
* ChartHelper.doChart(/test-src/solutions/samples/dashboard/departments.widget.xml", parameters, content, session,
* messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os = getOutputStream(SOLUTION_PATH,
* "ChartTest.testChartHelper_PieGrid", ".html"); //$NON-NLS-1$ //$NON-NLS-2$ os.write(content.toString().getBytes());
* } catch (Exception e) {
*
* } }
*
* public void testChartHelper_BarChart() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
* ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
* parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
* "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
* parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
* parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter(
* "drill-url", "SampleDashboard.jsp?region=" + region + "&department={DEPARTMENT}&measure={measure}");
* //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parameters.setParameter("series-name", "measure"); //$NON-NLS-1$
* //$NON-NLS-2$ parameters.setParameter("chart-type", "BarChart"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content =
* new StringBuffer(); StandaloneSession session = new
* StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
* ChartHelper.doChart("/test-src/solutions/samples/dashboard/departments.widget.xml", parameters, content, session,
* messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os = getOutputStream(SOLUTION_PATH,
* "ChartTest.testChartHelper_BarChart", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
* os.write(content.toString().getBytes()); } catch (Exception e) {
*
* } }
*/
/*
* public void testChartHelper_LineChart() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
* ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
* parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
* "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
* parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
* parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter(
* "drill-url", "SampleDashboard.jsp?region=" + region + "&department={DEPARTMENT}&measure={measure}");
* //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ parameters.setParameter("series-name", "measure"); //$NON-NLS-1$
* //$NON-NLS-2$ parameters.setParameter("chart-type", "LineChart"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content
* = new StringBuffer(); StandaloneSession session = new
* StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
* ChartHelper.doChart("/test-src/solutions/samples/dashboard/departments.widget.xml", parameters, content, session,
* messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os = getOutputStream(SOLUTION_PATH,
* "ChartTest.testChartHelper_LineChart", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
* os.write(content.toString().getBytes()); } catch (Exception e) {
*
* } }
*/
/*
* public void testChartHelper_AreaChart() { String region = "Central"; //$NON-NLS-1$ ArrayList messages = new
* ArrayList(); SimpleParameterProvider parameters = new SimpleParameterProvider();
* parameters.setParameter("image-width", "450"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("image-height",
* "300"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("REGION", region); //$NON-NLS-1$
* parameters.setParameter("outer-params", "REGION"); //$NON-NLS-1$ //$NON-NLS-2$
* parameters.setParameter("inner-param", "DEPARTMENT"); //$NON-NLS-1$ //$NON-NLS-2$
* parameters.setParameter("connection", "SampleData"); //$NON-NLS-1$ //$NON-NLS-2$ parameters.setParameter("query",
* "select REGION, DEPARTMENT, MANAGER_NAME, EMAIL from DEPARTMENT_MANAGERS"); //$NON-NLS-1$ //$NON-NLS-2$
* parameters.setParameter( "drill-url", "SampleDashboard.jsp?region=" + region +
* "&department={DEPARTMENT}&measure={measure}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
* parameters.setParameter("series-name", "measure"); //$NON-NLS-1$ //$NON-NLS-2$
* parameters.setParameter("chart-type", "AreaChart"); //$NON-NLS-1$ //$NON-NLS-2$ StringBuffer content = new
* StringBuffer(); StandaloneSession session = new
* StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
* ChartHelper.doChart("/test-src/solutions/samples/dashboard/departments.widget.xml", parameters, content, session,
* messages, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { OutputStream os = getOutputStream(SOLUTION_PATH,
* "ChartTest.testChartHelper_AreaChart", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
* os.write(content.toString().getBytes()); } catch (Exception e) {
*
* } }
*/
public void testChartHelper_Null() {
// $NON-NLS-1$
String region = "Central";
ArrayList messages = new ArrayList();
SimpleParameterProvider parameters = new SimpleParameterProvider();
// $NON-NLS-1$ //$NON-NLS-2$
parameters.setParameter("image-width", "450");
// $NON-NLS-1$ //$NON-NLS-2$
parameters.setParameter("image-height", "300");
// $NON-NLS-1$
parameters.setParameter("REGION", region);
// $NON-NLS-1$ //$NON-NLS-2$
parameters.setParameter("outer-params", "REGION");
// $NON-NLS-1$ //$NON-NLS-2$
parameters.setParameter("inner-param", "DEPARTMENT");
parameters.setParameter("drill-url", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"SampleDashboard.jsp?region=" + region + "&department={DEPARTMENT}&measure={measure}");
// $NON-NLS-1$ //$NON-NLS-2$
parameters.setParameter("series-name", "measure");
// $NON-NLS-1$ //$NON-NLS-2$
parameters.setParameter("chart-type", "");
StringBuffer content = new StringBuffer();
StandaloneSession session = // $NON-NLS-1$
new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
PentahoSessionHolder.setSession(session);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ChartHelper.doChart("/samples/dashboard/departments.widget.xml", parameters, content, session, messages, null);
try {
// $NON-NLS-1$ //$NON-NLS-2$
OutputStream os = getOutputStream("ChartTest.testChartHelper_Null", ".html");
os.write(content.toString().getBytes());
} catch (Exception e) {
// ignore
}
}
use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.
the class ChartbeansIT method testChartbeansActionComponentOFC.
@SuppressWarnings("deprecation")
@Test
public void testChartbeansActionComponentOFC() {
microPlatform.init();
IPentahoUrlFactory urlFactory = new SimpleUrlFactory("");
ArrayList messages = new ArrayList();
SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
// $NON-NLS-1$ //$NON-NLS-2$
parameterProvider.setParameter("solution", "test");
// $NON-NLS-1$ //$NON-NLS-2$
parameterProvider.setParameter("path", "chartbeans");
// $NON-NLS-1$ //$NON-NLS-2$
parameterProvider.setParameter("action", "Chartbeans_All_Inclusive_OFC.xaction");
ActionComponent component = new ActionComponent("test/chartbeans/Chartbeans_All_Inclusive_OFC.xaction", null, IOutputHandler.OUTPUT_TYPE_DEFAULT, urlFactory, // $NON-NLS-1$
messages);
component.setParameterProvider(IParameterProvider.SCOPE_REQUEST, parameterProvider);
component.validate(session, null);
// $NON-NLS-1$ //$NON-NLS-2$
OutputStream outputStream = getOutputStream("Chartbeans.testChartbeansAllInclusive_OFC", ".html");
// $NON-NLS-1$
String result = component.getContent("text/html");
try {
outputStream.write(result.getBytes());
// $NON-NLS-1$
assertTrue(result.startsWith("<html><head>"));
// $NON-NLS-1$
assertTrue(result.indexOf("function getChartData") > 0);
// $NON-NLS-1$
assertTrue(result.indexOf("/*JSON*/") > 0);
// $NON-NLS-1$
assertTrue(result.indexOf("/*END_JSON*/") > 0);
// $NON-NLS-1$
assertTrue(result.indexOf("</body></html>") > 0);
} catch (Exception e) {
// $NON-NLS-1$
assertTrue("An exception has been thrown: " + e.getMessage(), false);
}
}
Aggregations