Skip to content

Commit

Permalink
Prepare for Java > 8 #609
Browse files Browse the repository at this point in the history
Unit test fixes
  • Loading branch information
wimjongman committed Apr 15, 2021
1 parent 0f2a4f2 commit b82335b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
import junit.framework.TestCase;

/**
*
*
*/
public class ExpressionUtilTest extends TestCase {

@Test
public void testToNewExpression() {
ExpressionUtil.resetSuffix();

String[] oldExpressions = new String[] { null, " " + Messages.getString("ExpressionUtilTest.old.0"),
Messages.getString("ExpressionUtilTest.old.1"), Messages.getString("ExpressionUtilTest.old.2"),
Messages.getString("ExpressionUtilTest.old.3"), Messages.getString("ExpressionUtilTest.old.4"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/**
* This class help to manipulate expressions.
*
*
*/
public final class ExpressionUtil {

Expand Down Expand Up @@ -56,17 +56,25 @@ public final class ExpressionUtil {

/**
* Return a row expression text according to given row name.
*
*
* @param rowName
* @return
*/
public static String createRowExpression(String rowName) {
return createJSRowExpression(rowName);
}

/**
* When tests repeat, the static suffix has a wrong value. This method enables
* tests to reset the suffix.
*/
public static void resetSuffix() {
suffix = 0;
}

/**
* Return a dataSetRow expression text according to given row name.
*
*
* @param rowName
* @return
*/
Expand All @@ -76,7 +84,7 @@ public static String createDataSetRowExpression(String rowName) {

/**
* Return a JS row expression text according to given row name.
*
*
* @param rowName
* @return
*/
Expand All @@ -86,7 +94,7 @@ public static String createJSRowExpression(String rowName) {

/**
* Return a JS measure expression text according to given measure name.
*
*
* @param measureName
* @return
*/
Expand All @@ -96,7 +104,7 @@ public static String createJSMeasureExpression(String measureName) {

/**
* Return a JS data expression text according to given data name.
*
*
* @param dataName
* @return
*/
Expand All @@ -107,7 +115,7 @@ public static String createJSDataExpression(String dataName) {
/**
* Return a JS dimension expression text according to given dimension and
* measure name.By default it is reference to "ID" attribute of that level.
*
*
* @param dimensionName
* @param levelName
* @return
Expand All @@ -119,7 +127,7 @@ public static String createJSDimensionExpression(String dimensionName, String le
/**
* Return a JS dimension expression text according to given dimension and
* measure name.
*
*
* @param dimensionName
* @param levelName
* @param attributeName
Expand All @@ -132,7 +140,7 @@ public static String createJSDimensionExpression(String dimensionName, String le

/**
* Return a JS dataSetRow expression text according to given row name.
*
*
* @param rowName
* @return
*/
Expand All @@ -142,7 +150,7 @@ public static String createJSDataSetRowExpression(String rowName) {

/**
* Return a JS parameter expression text according to given row name.
*
*
* @param rowName
* @return
*/
Expand All @@ -152,7 +160,7 @@ public static String createJSParameterExpression(String parameterName) {

/**
* Return a JavaScript parameter value according to an expression.
*
*
* @param expression
* @return
*/
Expand All @@ -166,7 +174,7 @@ private static String createJSExprComponent(String value) {

/**
* Return a row expression text according to given row index, which is 1-based.
*
*
* @param index
* @return
* @deprecated
Expand All @@ -177,7 +185,7 @@ public static String createRowExpression(int index) {

/**
* Extract all column expression info
*
*
* @param oldExpression
* @return
* @throws BirtException
Expand All @@ -189,7 +197,7 @@ public static List<IColumnBinding> extractColumnExpressions(String oldExpression
/**
* Get the simplest column binding name. Such as row["col1"] pattern, we will
* return the column name "col1"
*
*
* @param oldExpression
* @return
* @throws BirtException
Expand All @@ -205,7 +213,7 @@ public static String getColumnBindingName(String oldExpression) throws BirtExcep
/**
* Get the simplest column binding name. Such as dataSetRow["col1"] pattern, we
* will return the column name "col1"
*
*
* @param oldExpression
* @return
* @throws BirtException
Expand All @@ -221,7 +229,7 @@ public static String getColumnName(String oldExpression) throws BirtException {

/**
* Extract all column expression info
*
*
* @param oldExpression
* @param mode if true, it means to compile the "row" expression.else
* extract "dataSetRow" expression
Expand All @@ -239,7 +247,7 @@ public static List<IColumnBinding> extractColumnExpressions(String oldExpression

/**
* Extract all column expression info
*
*
* @param oldExpression
* @param mode if true, it means to compile the "row" expression.else
* extract "dataSetRow" expression
Expand All @@ -261,7 +269,7 @@ public static List<IColumnBinding> extractColumnExpressions(String oldExpression

/**
* whethter the expression has aggregation
*
*
* @param oldExpression
* @return
* @throws BirtException
Expand All @@ -280,7 +288,7 @@ public static boolean hasAggregation(String expression) {

/**
* Return an IColumnBinding instance according to given oldExpression.
*
*
* @param oldExpression
* @return
*/
Expand All @@ -292,7 +300,7 @@ public static IColumnBinding getColumnBinding(String oldExpression) {
/**
* Translate the old expression with "row" as indicator to new expression using
* "dataSetRow" as indicator.
*
*
* @param oldExpression
* @return
*/
Expand Down Expand Up @@ -340,7 +348,7 @@ public static String toNewExpression(String oldExpression) {
/**
* Translate the old expression with "rows" as parent query indicator to new
* expression using "row._outer" as parent query indicator.
*
*
* @param oldExpression
* @param isParameterBinding
* @return
Expand Down Expand Up @@ -400,7 +408,7 @@ public static String updateParentQueryReferenceExpression(String oldExpression,
/**
* whether the exression is report paramter reference.The pattern should like
* params["aa"].if yes, return true. else return false;
*
*
* @param expression
*/
public static boolean isScalarParamReference(String expression) {
Expand All @@ -412,7 +420,7 @@ public static boolean isScalarParamReference(String expression) {

/**
* This method is used to provide information necessary for next step parsing.
*
*
* @param chars
* @param i
* @param omitNextQuote
Expand Down Expand Up @@ -473,7 +481,7 @@ private static ParseIndicator getParseIndicator(char[] chars, int i, boolean omi

/**
* Test whether the char immediately before the candidate "row" key is valid.
*
*
* @param operator
* @return
*/
Expand All @@ -485,7 +493,7 @@ private static boolean isValidProceeding(char operator) {
}

/**
*
*
* @param jointColumName
* @return
*/
Expand All @@ -507,13 +515,13 @@ public static String[] getSourceDataSetNames(String jointColumName) {
/**
* Gets the data set name with the given full name. The full name may contain
* the library namespace.
*
*
* <p>
* For example,
* <ul>
* <li>"dataSet1" is extracted from "new_library.dataSet1"
* </ul>
*
*
* @param fullDataSetName the data set
* @return the name
*/
Expand All @@ -532,7 +540,7 @@ public static String getDataSetNameWithoutPrefix(String fullDataSetName) {
}

/**
*
*
* @param expr
* @return
* @throws CoreException
Expand All @@ -542,11 +550,11 @@ public static Set<IDimLevel> getReferencedDimLevel(String expr) throws CoreExcep
}

/**
*
*
* @param expr
*
*
* @deprecated replaced by getAllReferencedMeasures
*
*
* @return get the first measure name in this expression
* @throws CoreException
*/
Expand All @@ -556,7 +564,7 @@ public static String getReferencedMeasure(String expr) throws CoreException {
}

/**
*
*
* @param expr
* @return get the referenced measure name in this expression
* @throws CoreException
Expand All @@ -566,7 +574,7 @@ public static Set<String> getAllReferencedMeasures(String expr) throws CoreExcep
}

/**
*
*
* @param expr
* @param paramOldName
* @param paramNewName
Expand All @@ -584,7 +592,7 @@ public static String replaceParameterName(String expr, String paramOldName, Stri
/**
* Generate a Javascript constant expression by user input string and target
* BIRT data type.
*
*
* @param input user input string.
* @param dataType target BIRT data type. available values defined in
* {@code org.eclipse.birt.core.data.DataType}
Expand All @@ -608,7 +616,7 @@ public static String generateConstantExpr(String input, int dataType) throws Bir

/**
* A utility class for internal use only.
*
*
*/
class ParseIndicator {

Expand Down

0 comments on commit b82335b

Please sign in to comment.