Search in sources :

Example 1 with CustomizedFunctionTable

use of mondrian.olap.fun.CustomizedFunctionTable in project mondrian by pentaho.

the class CustomizedParserTest method testMultiplicationFail.

public void testMultiplicationFail() {
    Set<String> functionNameSet = new HashSet<String>();
    functionNameSet.add("+");
    CustomizedFunctionTable cftab = getCustomizedFunctionTable(functionNameSet);
    try {
        Query q = getParsedQueryForExpr(cftab, "([Measures].[Store Cost] * [Measures].[Unit Sales])");
        q.resolve(q.createValidator(cftab, true));
        // Shouldn't reach here
        fail("Expected error did not occur.");
    } catch (Throwable e) {
        checkErrorMsg(e, "Mondrian Error:No function matches signature '<Member> * <Member>'");
    }
}
Also used : CustomizedFunctionTable(mondrian.olap.fun.CustomizedFunctionTable) HashSet(java.util.HashSet)

Example 2 with CustomizedFunctionTable

use of mondrian.olap.fun.CustomizedFunctionTable in project mondrian by pentaho.

the class CustomizedParserTest method testMissingObject.

private void testMissingObject(boolean strictValidation) {
    Set<String> functionNameSet = new HashSet<String>();
    functionNameSet.add("+");
    CustomizedFunctionTable cftab = getCustomizedFunctionTable(functionNameSet);
    MondrianProperties properties = MondrianProperties.instance();
    propSaver.set(properties.IgnoreInvalidMembers, true);
    propSaver.set(properties.IgnoreInvalidMembersDuringQuery, true);
    try {
        Query q = getParsedQueryForExpr(cftab, "'[Measures].[Store Cost] + [Measures].[Unit Salese]'", strictValidation);
        q.resolve(q.createValidator(cftab, true));
        // Shouldn't reach here if strictValidation
        fail("Expected error does not occur when strictValidation is set:" + strictValidation);
    } catch (Throwable e) {
        if (strictValidation) {
            checkErrorMsg(e, "Mondrian Error:MDX object '[Measures].[Unit Salese]' not found in cube 'Sales'");
        } else {
            checkErrorMsg(e, "Expected error does not occur when strictValidation is set:" + strictValidation);
        }
    }
}
Also used : CustomizedFunctionTable(mondrian.olap.fun.CustomizedFunctionTable) HashSet(java.util.HashSet)

Example 3 with CustomizedFunctionTable

use of mondrian.olap.fun.CustomizedFunctionTable in project mondrian by pentaho.

the class CustomizedParserTest method testCrossJoinFail.

public void testCrossJoinFail() {
    Set<String> functionNameSet = new HashSet<String>();
    functionNameSet.add("+");
    functionNameSet.add("-");
    functionNameSet.add("*");
    functionNameSet.add("/");
    CustomizedFunctionTable cftab = getCustomizedFunctionTable(functionNameSet);
    try {
        Query q = getParsedQueryForExpr(cftab, "CrossJoin([Measures].[Store Cost], [Measures].[Unit Sales])");
        q.resolve(q.createValidator(cftab, true));
        // Shouldn't reach here
        fail("Expected error did not occur.");
    } catch (Throwable e) {
        checkErrorMsg(e, "Mondrian Error:Tuple contains more than one member of hierarchy '[Measures]'.");
    }
}
Also used : CustomizedFunctionTable(mondrian.olap.fun.CustomizedFunctionTable) HashSet(java.util.HashSet)

Example 4 with CustomizedFunctionTable

use of mondrian.olap.fun.CustomizedFunctionTable in project mondrian by pentaho.

the class CustomizedParserTest method testSingleMultiplication.

public void testSingleMultiplication() {
    Set<String> functionNameSet = new HashSet<String>();
    functionNameSet.add("*");
    CustomizedFunctionTable cftab = getCustomizedFunctionTable(functionNameSet);
    try {
        Query q = getParsedQueryForExpr(cftab, "[Measures].[Store Cost] * [Measures].[Unit Sales]");
        q.resolve(q.createValidator(cftab, true));
    } catch (Throwable e) {
        fail(e.getMessage());
    }
}
Also used : CustomizedFunctionTable(mondrian.olap.fun.CustomizedFunctionTable) HashSet(java.util.HashSet)

Example 5 with CustomizedFunctionTable

use of mondrian.olap.fun.CustomizedFunctionTable in project mondrian by pentaho.

the class CustomizedParserTest method testMissingObjectFail.

public void testMissingObjectFail() {
    Set<String> functionNameSet = new HashSet<String>();
    functionNameSet.add("+");
    CustomizedFunctionTable cftab = getCustomizedFunctionTable(functionNameSet);
    try {
        Query q = getParsedQueryForExpr(cftab, "'[Measures].[Store Cost] + [Measures].[Unit Salese]'");
        q.resolve(q.createValidator(cftab, true));
        // Shouldn't reach here
        fail("Expected error did not occur.");
    } catch (Throwable e) {
        checkErrorMsg(e, "Mondrian Error:MDX object '[Measures].[Unit Salese]' not found in cube 'Sales'");
    }
}
Also used : CustomizedFunctionTable(mondrian.olap.fun.CustomizedFunctionTable) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)14 CustomizedFunctionTable (mondrian.olap.fun.CustomizedFunctionTable)14 ParenthesesFunDef (mondrian.olap.fun.ParenthesesFunDef)1