You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2013/07/31 10:12:56 UTC
[11/22] eliminate checkstyle warnings
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImplTool.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImplTool.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImplTool.java
index 7786c58..203344b 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImplTool.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImplTool.java
@@ -30,13 +30,11 @@ import org.apache.olingo.odata2.api.uri.expression.MethodOperator;
*/
public class FilterParserImplTool extends FilterParserImpl {
- public FilterParserImplTool(final EdmEntityType resourceEntityType)
- {
+ public FilterParserImplTool(final EdmEntityType resourceEntityType) {
super(resourceEntityType);
}
- public void addTestfunctions()
- {
+ public void addTestfunctions() {
Map<String, InfoMethod> lAvailableMethods = new HashMap<String, InfoMethod>(availableMethods);
ParameterSetCombination combination = null;
//create type helpers
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/FilterToJsonTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/FilterToJsonTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/FilterToJsonTest.java
index 5cc94b0..7274a6c 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/FilterToJsonTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/FilterToJsonTest.java
@@ -23,10 +23,6 @@ import static org.junit.Assert.assertNotNull;
import java.util.List;
-import org.junit.Test;
-
-import com.google.gson.Gson;
-import com.google.gson.internal.StringMap;
import org.apache.olingo.odata2.api.exception.ODataApplicationException;
import org.apache.olingo.odata2.api.uri.UriParser;
import org.apache.olingo.odata2.api.uri.expression.ExceptionVisitExpression;
@@ -34,6 +30,10 @@ import org.apache.olingo.odata2.api.uri.expression.ExpressionKind;
import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
import org.apache.olingo.odata2.api.uri.expression.MethodOperator;
import org.apache.olingo.odata2.api.uri.expression.UnaryOperator;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+import com.google.gson.internal.StringMap;
/**
*
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/ParserTool.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/ParserTool.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/ParserTool.java
index 044d6d8..0600f64 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/ParserTool.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/ParserTool.java
@@ -24,10 +24,6 @@ import static org.junit.Assert.fail;
import java.util.Locale;
import org.apache.log4j.xml.DOMConfigurator;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.apache.olingo.odata2.api.edm.EdmEntityType;
import org.apache.olingo.odata2.api.edm.EdmException;
import org.apache.olingo.odata2.api.edm.EdmProperty;
@@ -43,6 +39,9 @@ import org.apache.olingo.odata2.api.uri.expression.ExpressionVisitor;
import org.apache.olingo.odata2.api.uri.expression.SortOrder;
import org.apache.olingo.odata2.core.exception.MessageService;
import org.apache.olingo.odata2.core.exception.MessageService.Message;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -384,8 +383,7 @@ public class ParserTool {
public ParserTool aExpr() {
String info = "GetExpr(" + expression + ")-->";
- if ((curNode.getKind() != ExpressionKind.ORDER)
- && (curNode.getKind() != ExpressionKind.FILTER)) {
+ if ((curNode.getKind() != ExpressionKind.ORDER) && (curNode.getKind() != ExpressionKind.FILTER)) {
String out = info + "Expected: " + ExpressionKind.ORDER + " or " + ExpressionKind.FILTER + " Actual: " + curNode.getKind().toString();
dout(" " + out);
fail(out);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestAbapCompatibility.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestAbapCompatibility.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestAbapCompatibility.java
index 4eb2d61..7df85c6 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestAbapCompatibility.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestAbapCompatibility.java
@@ -18,8 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;
-import org.junit.Test;
-
import org.apache.olingo.odata2.core.edm.Bit;
import org.apache.olingo.odata2.core.edm.EdmBinary;
import org.apache.olingo.odata2.core.edm.EdmBoolean;
@@ -38,6 +36,7 @@ import org.apache.olingo.odata2.core.edm.EdmSingle;
import org.apache.olingo.odata2.core.edm.EdmString;
import org.apache.olingo.odata2.core.edm.EdmTime;
import org.apache.olingo.odata2.core.edm.Uint7;
+import org.junit.Test;
/**
*
@@ -371,22 +370,19 @@ public class TestAbapCompatibility extends TestBase {
//iv_expression = `concat('a' 'b')`
//iv_expected_textid = /iwcor/cx_ds_expr_syntax_error=>function_invalid_parameter
//iv_expected_msg = 'Invalid parameter for function ''concat''' ).
- GetPTF("concat('a' 'b')")
- .aExMsgText("\")\" or \",\" expected after position 10 in \"concat('a' 'b')\".");
+ GetPTF("concat('a' 'b')").aExMsgText("\")\" or \",\" expected after position 10 in \"concat('a' 'b')\".");
//lcl_helper=>veri_expression_ex(
//iv_expression = `concat('125')`
//iv_expected_textid = /iwcor/cx_ds_expr_syntax_error=>function_to_few_parameter
//iv_expected_msg = 'Too few parameters for function ''concat''' ).
- GetPTF("concat('125')")
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"concat('125')\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
+ GetPTF("concat('125')").aExMsgText("No applicable method found for \"concat\" at position 1 in \"concat('125')\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
//lcl_helper=>veri_expression_ex(
//iv_expression = `indexof('a','b','c')`
//iv_expected_textid = /iwcor/cx_ds_expr_syntax_error=>function_to_many_parameter
//iv_expected_msg = 'Too many parameters for function ''indexof''' ).
- GetPTF("indexof('a','b','c')")
- .aExMsgText("No applicable method found for \"indexof\" at position 1 in \"indexof('a','b','c')\" with the specified arguments. Method \"indexof\" requires exact 2 argument(s).");
+ GetPTF("indexof('a','b','c')").aExMsgText("No applicable method found for \"indexof\" at position 1 in \"indexof('a','b','c')\" with the specified arguments. Method \"indexof\" requires exact 2 argument(s).");
//lcl_helper=>veri_expression_ex(
//iv_expression = `replace('aBa','B','CCC')`
@@ -406,8 +402,7 @@ public class TestAbapCompatibility extends TestBase {
//http://services.odata.org/Northwind/Northwind.svc/Products/?$filter=replace('aBa','B','CCC')
//-->Unknown function 'replace' at position 0.
- GetPTF("replace('aBa','B','CCC')")
- .aExMsgText("Unknown function \"replace\" at position 1 in \"replace('aBa','B','CCC')\".");
+ GetPTF("replace('aBa','B','CCC')").aExMsgText("Unknown function \"replace\" at position 1 in \"replace('aBa','B','CCC')\".");
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestBase.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestBase.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestBase.java
index 2c1cec8..c3d4ce9 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestBase.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestBase.java
@@ -49,8 +49,7 @@ public class TestBase {
}
static public ParserTool GetPTF(final EdmEntityType resourceEntityType, final String expression) {
- return new ParserTool(expression, false, true, false,
- resourceEntityType);
+ return new ParserTool(expression, false, true, false, resourceEntityType);
}
static public ParserTool GetPTO(final String expression) {
@@ -66,8 +65,7 @@ public class TestBase {
}
static public ParserTool GetPTF_noTEST(final EdmEntityType resourceEntityType, final String expression) {
- return new ParserTool(expression, false, false, true,
- resourceEntityType);
+ return new ParserTool(expression, false, false, true, resourceEntityType);
}
static public ParserTool GetPTO_noTEST(final String expression) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestExceptionTexts.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestExceptionTexts.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestExceptionTexts.java
index 2621fa6..b4a27a0 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestExceptionTexts.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestExceptionTexts.java
@@ -18,11 +18,10 @@
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;
-import org.junit.Test;
-
import org.apache.olingo.odata2.api.uri.expression.ExceptionVisitExpression;
import org.apache.olingo.odata2.api.uri.expression.ExpressionParserException;
import org.apache.olingo.odata2.testutil.helper.ODataMessageTextVerifier;
+import org.junit.Test;
/**
*
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParser.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParser.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParser.java
index a920f1c..bb335f7 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParser.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParser.java
@@ -24,8 +24,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
-
import org.apache.olingo.odata2.api.edm.EdmComplexType;
import org.apache.olingo.odata2.api.edm.EdmEntityType;
import org.apache.olingo.odata2.api.edm.EdmException;
@@ -52,6 +50,7 @@ import org.apache.olingo.odata2.core.edm.EdmString;
import org.apache.olingo.odata2.core.edm.EdmTime;
import org.apache.olingo.odata2.core.edm.Uint7;
import org.apache.olingo.odata2.core.edm.provider.EdmComplexPropertyImplProv;
+import org.junit.Test;
/**
*
@@ -85,10 +84,7 @@ public class TestParser extends TestBase {
GetPTO("sven desc, test desc").aSerialized("{oc({o(sven, desc)},{o(test, desc)})}");
GetPTO("'sven', 77").order(1).aSortOrder(SortOrder.asc);
- GetPTO("'sven', 77 desc")
- .root().order(0).aSortOrder(SortOrder.asc).aExpr().aEdmType(EdmString.getInstance())
- .root().order(1).aSortOrder(SortOrder.desc).aExpr()
- .aEdmType(Uint7.getInstance());
+ GetPTO("'sven', 77 desc").root().order(0).aSortOrder(SortOrder.asc).aExpr().aEdmType(EdmString.getInstance()).root().order(1).aSortOrder(SortOrder.desc).aExpr().aEdmType(Uint7.getInstance());
}
@@ -133,21 +129,13 @@ public class TestParser extends TestBase {
@Test
public void testProperties() {
// GetPTF("sven").aSerialized("sven").aKind(ExpressionKind.PROPERTY);
- GetPTF("sven1 add sven2").aSerialized("{sven1 add sven2}")
- .aKind(ExpressionKind.BINARY)
- .root().left().aKind(ExpressionKind.PROPERTY).aUriLiteral("sven1")
- .root().right().aKind(ExpressionKind.PROPERTY).aUriLiteral("sven2");
+ GetPTF("sven1 add sven2").aSerialized("{sven1 add sven2}").aKind(ExpressionKind.BINARY).root().left().aKind(ExpressionKind.PROPERTY).aUriLiteral("sven1").root().right().aKind(ExpressionKind.PROPERTY).aUriLiteral("sven2");
}
@Test
public void testDeepProperties() {
GetPTF("a/b").aSerialized("{a/b}").aKind(ExpressionKind.MEMBER);
- GetPTF("a/b/c").aSerialized("{{a/b}/c}")
- .root().aKind(ExpressionKind.MEMBER)
- .root().left().aKind(ExpressionKind.MEMBER)
- .root().left().left().aKind(ExpressionKind.PROPERTY).aUriLiteral("a")
- .root().left().right().aKind(ExpressionKind.PROPERTY).aUriLiteral("b")
- .root().right().aKind(ExpressionKind.PROPERTY).aUriLiteral("c");
+ GetPTF("a/b/c").aSerialized("{{a/b}/c}").root().aKind(ExpressionKind.MEMBER).root().left().aKind(ExpressionKind.MEMBER).root().left().left().aKind(ExpressionKind.PROPERTY).aUriLiteral("a").root().left().right().aKind(ExpressionKind.PROPERTY).aUriLiteral("b").root().right().aKind(ExpressionKind.PROPERTY).aUriLiteral("c");
}
@Test
@@ -167,29 +155,16 @@ public class TestParser extends TestBase {
GetPTF(edmEtAllTypes, "String").aEdmProperty(string).aEdmType(stringType);
- GetPTF(edmEtAllTypes, "'text' eq String")
- .root().aKind(ExpressionKind.BINARY);
+ GetPTF(edmEtAllTypes, "'text' eq String").root().aKind(ExpressionKind.BINARY);
- GetPTF(edmEtAllTypes, "Complex/String")
- .root().left().aEdmProperty(complex).aEdmType(complexType)
- .root().right().aEdmProperty(complexString).aEdmType(complexStringType)
- .root().aKind(ExpressionKind.MEMBER).aEdmType(complexStringType);
+ GetPTF(edmEtAllTypes, "Complex/String").root().left().aEdmProperty(complex).aEdmType(complexType).root().right().aEdmProperty(complexString).aEdmType(complexStringType).root().aKind(ExpressionKind.MEMBER).aEdmType(complexStringType);
- GetPTF(edmEtAllTypes, "Complex/Address/City")
- .root().aKind(ExpressionKind.MEMBER)
- .root().left().aKind(ExpressionKind.MEMBER)
- .root().left().left().aKind(ExpressionKind.PROPERTY).aEdmProperty(complex).aEdmType(complexType)
- .root().left().right().aKind(ExpressionKind.PROPERTY).aEdmProperty(complexAddress).aEdmType(complexAddressType)
- .root().left().aEdmType(complexAddressType)
- .root().right().aKind(ExpressionKind.PROPERTY).aEdmProperty(complexAddressCity).aEdmType(complexAddressCityType)
- .root().aEdmType(complexAddressCityType);
+ GetPTF(edmEtAllTypes, "Complex/Address/City").root().aKind(ExpressionKind.MEMBER).root().left().aKind(ExpressionKind.MEMBER).root().left().left().aKind(ExpressionKind.PROPERTY).aEdmProperty(complex).aEdmType(complexType).root().left().right().aKind(ExpressionKind.PROPERTY).aEdmProperty(complexAddress).aEdmType(complexAddressType).root().left().aEdmType(complexAddressType).root().right().aKind(ExpressionKind.PROPERTY).aEdmProperty(complexAddressCity).aEdmType(complexAddressCityType).root().aEdmType(complexAddressCityType);
EdmProperty boolean_ = (EdmProperty) edmEtAllTypes.getProperty("Boolean");
EdmSimpleType boolean_Type = (EdmSimpleType) boolean_.getType();
- GetPTF(edmEtAllTypes, "not Boolean").aKind(ExpressionKind.UNARY)
- .aEdmType(boolean_Type).right().aEdmProperty(boolean_)
- .aEdmType(boolean_Type);
+ GetPTF(edmEtAllTypes, "not Boolean").aKind(ExpressionKind.UNARY).aEdmType(boolean_Type).right().aEdmProperty(boolean_).aEdmType(boolean_Type);
} catch (EdmException e) {
fail("Error in testPropertiesWithEdm:" + e.getLocalizedMessage());
@@ -220,10 +195,7 @@ public class TestParser extends TestBase {
GetPTF("1d add 2d").aSerialized("{1d add 2d}");
GetPTF("1d div 2d").aSerialized("{1d div 2d}");
- GetPTF("1d add 2d").aSerialized("{1d add 2d}")
- .aKind(ExpressionKind.BINARY)
- .root().left().aKind(ExpressionKind.LITERAL)
- .root().right().aKind(ExpressionKind.LITERAL);
+ GetPTF("1d add 2d").aSerialized("{1d add 2d}").aKind(ExpressionKind.BINARY).root().left().aKind(ExpressionKind.LITERAL).root().right().aKind(ExpressionKind.LITERAL);
}
@@ -359,86 +331,51 @@ public class TestParser extends TestBase {
EdmString stringInst = EdmString.getInstance();
EdmTime timeInst = EdmTime.getInstance();
- GetPTF("X'Fa12aAA1'").aUriLiteral("X'Fa12aAA1'")
- .aKind(ExpressionKind.LITERAL).aEdmType(binaryInst);
- GetPTF("binary'FA12AAA1'").aUriLiteral("binary'FA12AAA1'")
- .aKind(ExpressionKind.LITERAL).aEdmType(binaryInst);
-
- GetPTF("true").aUriLiteral("true").aKind(ExpressionKind.LITERAL)
- .aEdmType(boolInst);
- GetPTF("false").aUriLiteral("false").aKind(ExpressionKind.LITERAL)
- .aEdmType(boolInst);
-
- GetPTF("1").aUriLiteral("1").aKind(ExpressionKind.LITERAL)
- .aEdmType(bitInst);
- GetPTF("0").aUriLiteral("0").aKind(ExpressionKind.LITERAL)
- .aEdmType(bitInst);
-
- GetPTF("255").aUriLiteral("255").aKind(ExpressionKind.LITERAL)
- .aEdmType(byteInst);
-
- GetPTF("123").aUriLiteral("123").aKind(ExpressionKind.LITERAL)
- .aEdmType(Uint7Inst);
-
- GetPTF("datetime'2009-12-26T21:23:38'")
- .aUriLiteral("datetime'2009-12-26T21:23:38'")
- .aKind(ExpressionKind.LITERAL).aEdmType(datetimeInst);
- GetPTF("datetime'2009-12-26T21:23:38'")
- .aUriLiteral("datetime'2009-12-26T21:23:38'")
- .aKind(ExpressionKind.LITERAL).aEdmType(datetimeInst);
-
- GetPTF("datetimeoffset'2009-12-26T21:23:38Z'")
- .aUriLiteral("datetimeoffset'2009-12-26T21:23:38Z'")
- .aKind(ExpressionKind.LITERAL).aEdmType(datetimeOffsetInst);
- GetPTF("datetimeoffset'2002-10-10T12:00:00-05:00'")
- .aUriLiteral("datetimeoffset'2002-10-10T12:00:00-05:00'")
- .aKind(ExpressionKind.LITERAL).aEdmType(datetimeOffsetInst);
-
- GetPTF("4.5m").aUriLiteral("4.5m").aKind(ExpressionKind.LITERAL)
- .aEdmType(decimalInst);
- GetPTF("4.5M").aUriLiteral("4.5M").aKind(ExpressionKind.LITERAL)
- .aEdmType(decimalInst);
-
- GetPTF("4.5d").aUriLiteral("4.5d").aKind(ExpressionKind.LITERAL)
- .aEdmType(doubleInst);
- GetPTF("4.5D").aUriLiteral("4.5D").aKind(ExpressionKind.LITERAL)
- .aEdmType(doubleInst);
-
- GetPTF("guid'1225c695-cfb8-4ebb-aaaa-80da344efa6a'")
- .aUriLiteral("guid'1225c695-cfb8-4ebb-aaaa-80da344efa6a'")
- .aKind(ExpressionKind.LITERAL).aEdmType(guidInst);
-
- GetPTF("-32768").aUriLiteral("-32768").aKind(ExpressionKind.LITERAL)
- .aEdmType(int16Inst);
- GetPTF("3276").aUriLiteral("3276").aKind(ExpressionKind.LITERAL)
- .aEdmType(int16Inst);
- GetPTF("32767").aUriLiteral("32767").aKind(ExpressionKind.LITERAL)
- .aEdmType(int16Inst);
-
- GetPTF("-327687").aUriLiteral("-327687").aKind(ExpressionKind.LITERAL)
- .aEdmType(int32Inst);
- GetPTF("32768").aUriLiteral("32768").aKind(ExpressionKind.LITERAL)
- .aEdmType(int32Inst);
- GetPTF("327686").aUriLiteral("327686").aKind(ExpressionKind.LITERAL)
- .aEdmType(int32Inst);
-
- GetPTF("64L").aUriLiteral("64L").aKind(ExpressionKind.LITERAL)
- .aEdmType(int64Inst);
- GetPTF("64l").aUriLiteral("64l").aKind(ExpressionKind.LITERAL)
- .aEdmType(int64Inst);
-
- GetPTF("-123").aUriLiteral("-123").aKind(ExpressionKind.LITERAL)
- .aEdmType(intSByte);
- GetPTF("-128").aUriLiteral("-128").aKind(ExpressionKind.LITERAL)
- .aEdmType(intSByte);
-
- GetPTF("4.5f").aUriLiteral("4.5f").aKind(ExpressionKind.LITERAL)
- .aEdmType(singleInst);
-
- GetPTF("'abc'").aUriLiteral("'abc'").aKind(ExpressionKind.LITERAL)
- .aEdmType(stringInst);
- GetPTF("time'PT120S'").aUriLiteral("time'PT120S'")
- .aKind(ExpressionKind.LITERAL).aEdmType(timeInst);
+ GetPTF("X'Fa12aAA1'").aUriLiteral("X'Fa12aAA1'").aKind(ExpressionKind.LITERAL).aEdmType(binaryInst);
+ GetPTF("binary'FA12AAA1'").aUriLiteral("binary'FA12AAA1'").aKind(ExpressionKind.LITERAL).aEdmType(binaryInst);
+
+ GetPTF("true").aUriLiteral("true").aKind(ExpressionKind.LITERAL).aEdmType(boolInst);
+ GetPTF("false").aUriLiteral("false").aKind(ExpressionKind.LITERAL).aEdmType(boolInst);
+
+ GetPTF("1").aUriLiteral("1").aKind(ExpressionKind.LITERAL).aEdmType(bitInst);
+ GetPTF("0").aUriLiteral("0").aKind(ExpressionKind.LITERAL).aEdmType(bitInst);
+
+ GetPTF("255").aUriLiteral("255").aKind(ExpressionKind.LITERAL).aEdmType(byteInst);
+
+ GetPTF("123").aUriLiteral("123").aKind(ExpressionKind.LITERAL).aEdmType(Uint7Inst);
+
+ GetPTF("datetime'2009-12-26T21:23:38'").aUriLiteral("datetime'2009-12-26T21:23:38'").aKind(ExpressionKind.LITERAL).aEdmType(datetimeInst);
+ GetPTF("datetime'2009-12-26T21:23:38'").aUriLiteral("datetime'2009-12-26T21:23:38'").aKind(ExpressionKind.LITERAL).aEdmType(datetimeInst);
+
+ GetPTF("datetimeoffset'2009-12-26T21:23:38Z'").aUriLiteral("datetimeoffset'2009-12-26T21:23:38Z'").aKind(ExpressionKind.LITERAL).aEdmType(datetimeOffsetInst);
+ GetPTF("datetimeoffset'2002-10-10T12:00:00-05:00'").aUriLiteral("datetimeoffset'2002-10-10T12:00:00-05:00'").aKind(ExpressionKind.LITERAL).aEdmType(datetimeOffsetInst);
+
+ GetPTF("4.5m").aUriLiteral("4.5m").aKind(ExpressionKind.LITERAL).aEdmType(decimalInst);
+ GetPTF("4.5M").aUriLiteral("4.5M").aKind(ExpressionKind.LITERAL).aEdmType(decimalInst);
+
+ GetPTF("4.5d").aUriLiteral("4.5d").aKind(ExpressionKind.LITERAL).aEdmType(doubleInst);
+ GetPTF("4.5D").aUriLiteral("4.5D").aKind(ExpressionKind.LITERAL).aEdmType(doubleInst);
+
+ GetPTF("guid'1225c695-cfb8-4ebb-aaaa-80da344efa6a'").aUriLiteral("guid'1225c695-cfb8-4ebb-aaaa-80da344efa6a'").aKind(ExpressionKind.LITERAL).aEdmType(guidInst);
+
+ GetPTF("-32768").aUriLiteral("-32768").aKind(ExpressionKind.LITERAL).aEdmType(int16Inst);
+ GetPTF("3276").aUriLiteral("3276").aKind(ExpressionKind.LITERAL).aEdmType(int16Inst);
+ GetPTF("32767").aUriLiteral("32767").aKind(ExpressionKind.LITERAL).aEdmType(int16Inst);
+
+ GetPTF("-327687").aUriLiteral("-327687").aKind(ExpressionKind.LITERAL).aEdmType(int32Inst);
+ GetPTF("32768").aUriLiteral("32768").aKind(ExpressionKind.LITERAL).aEdmType(int32Inst);
+ GetPTF("327686").aUriLiteral("327686").aKind(ExpressionKind.LITERAL).aEdmType(int32Inst);
+
+ GetPTF("64L").aUriLiteral("64L").aKind(ExpressionKind.LITERAL).aEdmType(int64Inst);
+ GetPTF("64l").aUriLiteral("64l").aKind(ExpressionKind.LITERAL).aEdmType(int64Inst);
+
+ GetPTF("-123").aUriLiteral("-123").aKind(ExpressionKind.LITERAL).aEdmType(intSByte);
+ GetPTF("-128").aUriLiteral("-128").aKind(ExpressionKind.LITERAL).aEdmType(intSByte);
+
+ GetPTF("4.5f").aUriLiteral("4.5f").aKind(ExpressionKind.LITERAL).aEdmType(singleInst);
+
+ GetPTF("'abc'").aUriLiteral("'abc'").aKind(ExpressionKind.LITERAL).aEdmType(stringInst);
+ GetPTF("time'PT120S'").aUriLiteral("time'PT120S'").aKind(ExpressionKind.LITERAL).aEdmType(timeInst);
// The EdmSimpleTypeSamples contains a well formatted list of all
// possible
@@ -456,10 +393,8 @@ public class TestParser extends TestBase {
}
ExpressionParserException GetException() {
- ExpressionParserException ex = new ExpressionParserException(
- ExpressionParserException.COMMON_ERROR);
- List<StackTraceElement> stack = new ArrayList<StackTraceElement>(
- Arrays.asList(ex.getStackTrace()));
+ ExpressionParserException ex = new ExpressionParserException(ExpressionParserException.COMMON_ERROR);
+ List<StackTraceElement> stack = new ArrayList<StackTraceElement>(Arrays.asList(ex.getStackTrace()));
stack.remove(0);
ex.setStackTrace(stack.toArray(new StackTraceElement[stack.size()]));
return ex;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParserExceptions.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParserExceptions.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParserExceptions.java
index 49e2b72..edf2550 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParserExceptions.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestParserExceptions.java
@@ -18,11 +18,10 @@
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;
-import org.junit.Test;
-
import org.apache.olingo.odata2.api.edm.EdmEntityType;
import org.apache.olingo.odata2.api.uri.expression.ExpressionKind;
import org.apache.olingo.odata2.api.uri.expression.ExpressionParserException;
+import org.junit.Test;
/**
*
@@ -30,111 +29,91 @@ import org.apache.olingo.odata2.api.uri.expression.ExpressionParserException;
public class TestParserExceptions extends TestBase {
@Test
- public void testOPMparseOrderByString()
- {
+ public void testOPMparseOrderByString() {
EdmEntityType edmEtAllTypes = edmInfo.getTypeEtAllTypes();
//CASE 1
//http://services.odata.org/Northwind/Northwind.svc/Products/?$orderby=UnitPrice%20ascc
//-->Syntax error at position 10.
- GetPTO(edmEtAllTypes, "String ascc")
- .aExMsgText("Invalid sort order in OData orderby parser at position 8 in \"String ascc\".");
+ GetPTO(edmEtAllTypes, "String ascc").aExMsgText("Invalid sort order in OData orderby parser at position 8 in \"String ascc\".");
//CASE 2
//http://services.odata.org/Northwind/Northwind.svc/Products/?$orderby=UnitPrice%20asc,
//-->Expression expected at position 12.
- GetPTO(edmEtAllTypes, "String asc,")
- .aExMsgText("Expression expected after position 11 in \"String asc,\".");
+ GetPTO(edmEtAllTypes, "String asc,").aExMsgText("Expression expected after position 11 in \"String asc,\".");
//CASE 3
//http://services.odata.org/Northwind/Northwind.svc/Products/?$orderby=UnitPrice%20asc%20d
//-->Syntax error at position 14.
- GetPTO(edmEtAllTypes, "String asc a")
- .aExMsgText("Comma or end of expression expected at position 12 in \"String asc a\".");
+ GetPTO(edmEtAllTypes, "String asc a").aExMsgText("Comma or end of expression expected at position 12 in \"String asc a\".");
//CASE 4
//http://services.odata.org/Northwind/Northwind.svc/Products/?$orderby=UnitPrice b
//-->Syntax error at position 10.
- GetPTO(edmEtAllTypes, "String b")
- .aExMsgText("Invalid sort order in OData orderby parser at position 8 in \"String b\".");
+ GetPTO(edmEtAllTypes, "String b").aExMsgText("Invalid sort order in OData orderby parser at position 8 in \"String b\".");
//CASE 5
//http://services.odata.org/Northwind/Northwind.svc/Products/?$orderby=UnitPrice, UnitPrice b
//-->Syntax error at position 21.
- GetPTO(edmEtAllTypes, "String, String b")
- .aExMsgText("Invalid sort order in OData orderby parser at position 16 in \"String, String b\".");
+ GetPTO(edmEtAllTypes, "String, String b").aExMsgText("Invalid sort order in OData orderby parser at position 16 in \"String, String b\".");
//CASE 6
//http://services.odata.org/Northwind/Northwind.svc/Products/?$orderby=UnitPrice a, UnitPrice desc
//-->Syntax error at position 10.
- GetPTO(edmEtAllTypes, "String a, String desc")
- .aExMsgText("Invalid sort order in OData orderby parser at position 8 in \"String a, String desc\".");
+ GetPTO(edmEtAllTypes, "String a, String desc").aExMsgText("Invalid sort order in OData orderby parser at position 8 in \"String a, String desc\".");
//CASE 7
//http://services.odata.org/Northwind/Northwind.svc/Products/?$orderby=UnitPrice asc, UnitPrice b
//-->Syntax error at position 25.
- GetPTO(edmEtAllTypes, "String asc, String b")
- .aExMsgText("Invalid sort order in OData orderby parser at position 20 in \"String asc, String b\".");
+ GetPTO(edmEtAllTypes, "String asc, String b").aExMsgText("Invalid sort order in OData orderby parser at position 20 in \"String asc, String b\".");
}
@Test
- public void testPMvalidateEdmProperty()
- {
+ public void testPMvalidateEdmProperty() {
EdmEntityType edmEtAllTypes = edmInfo.getTypeEtAllTypes();
//OK
- GetPTF(edmEtAllTypes, "'text' eq String")
- .aKind(ExpressionKind.BINARY)
- .aSerialized("{'text' eq String}");
+ GetPTF(edmEtAllTypes, "'text' eq String").aKind(ExpressionKind.BINARY).aSerialized("{'text' eq String}");
//CASE 1
//http://services.odata.org/Northwind/Northwind.svc/Products/?$filter=NotAProperty
//-->No property 'NotAProperty' exists in type 'ODataWeb.Northwind.Model.Product' at position 10.
- GetPTF(edmEtAllTypes, "NotAProperty")
- .aExMsgText("No property \"NotAProperty\" exists in type \"TecRefScenario.EtAllTypes\" at position 1 in \"NotAProperty\".");
+ GetPTF(edmEtAllTypes, "NotAProperty").aExMsgText("No property \"NotAProperty\" exists in type \"TecRefScenario.EtAllTypes\" at position 1 in \"NotAProperty\".");
//CASE 2
//http://services.odata.org/Northwind/Northwind.svc/Products/?$filter='text'%20eq%20NotAProperty
//-->No property 'NotAProperty' exists in type 'ODataWeb.Northwind.Model.Product' at position 10.
- GetPTF(edmEtAllTypes, "'text' eq NotAProperty")
- .aExMsgText("No property \"NotAProperty\" exists in type \"TecRefScenario.EtAllTypes\" at position 11 in \"'text' eq NotAProperty\".");
+ GetPTF(edmEtAllTypes, "'text' eq NotAProperty").aExMsgText("No property \"NotAProperty\" exists in type \"TecRefScenario.EtAllTypes\" at position 11 in \"'text' eq NotAProperty\".");
//CASE 3
- GetPTF(edmEtAllTypes, "Complex/NotAProperty")
- .aExMsgText("No property \"NotAProperty\" exists in type \"TecRefScenario.CtAllTypes\" at position 9 in \"Complex/NotAProperty\".");
+ GetPTF(edmEtAllTypes, "Complex/NotAProperty").aExMsgText("No property \"NotAProperty\" exists in type \"TecRefScenario.CtAllTypes\" at position 9 in \"Complex/NotAProperty\".");
//CASE 4
- GetPTF(edmEtAllTypes, "'text' eq Complex/NotAProperty")
- .aExMsgText("No property \"NotAProperty\" exists in type \"TecRefScenario.CtAllTypes\" at position 19 in \"'text' eq Complex/NotAProperty\".");
+ GetPTF(edmEtAllTypes, "'text' eq Complex/NotAProperty").aExMsgText("No property \"NotAProperty\" exists in type \"TecRefScenario.CtAllTypes\" at position 19 in \"'text' eq Complex/NotAProperty\".");
//CASE 5
- GetPTF(edmEtAllTypes, "String/NotAProperty")
- .aExMsgText("No property \"NotAProperty\" exists in type \"Edm.String\" at position 8 in \"String/NotAProperty\".");
+ GetPTF(edmEtAllTypes, "String/NotAProperty").aExMsgText("No property \"NotAProperty\" exists in type \"Edm.String\" at position 8 in \"String/NotAProperty\".");
//CASE 6
//http://services.odata.org/Northwind/Northwind.svc/Products/?$filter='aText'/NotAProperty
//-->Exception Stack
- GetPTF(edmEtAllTypes, "'aText'/NotAProperty")
- .aExMsgText("Leftside of method operator at position 8 is not a property in \"'aText'/NotAProperty\".");
+ GetPTF(edmEtAllTypes, "'aText'/NotAProperty").aExMsgText("Leftside of method operator at position 8 is not a property in \"'aText'/NotAProperty\".");
//CASE 7
//http://services.odata.org/Northwind/Northwind.svc/Products/?$filter='Hong Kong' eq ProductName/city
//--> No property 'city' exists in type 'System.String' at position 27.
- GetPTF(edmEtAllTypes, "'Hong Kong' eq DateTime/city")
- .aExMsgText("No property \"city\" exists in type \"Edm.DateTime\" at position 25 in \"'Hong Kong' eq DateTime/city\".");
+ GetPTF(edmEtAllTypes, "'Hong Kong' eq DateTime/city").aExMsgText("No property \"city\" exists in type \"Edm.DateTime\" at position 25 in \"'Hong Kong' eq DateTime/city\".");
//CASE 8
//http://services.odata.org/Northwind/Northwind.svc/Products/?$filter='Hong Kong' eq ProductName/city
//--> No property 'city' exists in type 'System.String' at position 27.
- GetPTF(edmEtAllTypes, "'Hong Kong' eq String/city")
- .aExMsgText("No property \"city\" exists in type \"Edm.String\" at position 23 in \"'Hong Kong' eq String/city\".");
+ GetPTF(edmEtAllTypes, "'Hong Kong' eq String/city").aExMsgText("No property \"city\" exists in type \"Edm.String\" at position 23 in \"'Hong Kong' eq String/city\".");
}
@Test
- public void testPMreadParameters()
- {
+ public void testPMreadParameters() {
//OK
GetPTF("concat('A','B')").aSerialized("{concat('A','B')}");
@@ -142,14 +121,12 @@ public class TestParserExceptions extends TestBase {
//CASE 12
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=startswith()
//-->No applicable function found for 'startswith' at position 0 with the specified arguments. The functions considered are: startswith(System.String, System.String).
- GetPTF("startswith()").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"startswith\" at position 1 in \"startswith()\" with the specified arguments. Method \"startswith\" requires exact 2 argument(s).");
+ GetPTF("startswith()").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"startswith\" at position 1 in \"startswith()\" with the specified arguments. Method \"startswith\" requires exact 2 argument(s).");
//CASE 13
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=startswith('A')
//-->No applicable function found for 'startswith' at position 0 with the specified arguments. The functions considered are: startswith(System.String, System.String).
- GetPTF("startswith('A')").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"startswith\" at position 1 in \"startswith('A')\" with the specified arguments. Method \"startswith\" requires exact 2 argument(s).");
+ GetPTF("startswith('A')").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"startswith\" at position 1 in \"startswith('A')\" with the specified arguments. Method \"startswith\" requires exact 2 argument(s).");
//CASE 14
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=startswith('A','B')
@@ -159,50 +136,40 @@ public class TestParserExceptions extends TestBase {
//CASE 15
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=startswith('A','B','C')
//-->No applicable function found for 'startswith' at position 0 with the specified arguments. The functions considered are: startswith(System.String, System.String).
- GetPTF("startswith('A','B','C')").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"startswith\" at position 1 in \"startswith('A','B','C')\" with the specified arguments. Method \"startswith\" requires exact 2 argument(s).");
+ GetPTF("startswith('A','B','C')").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"startswith\" at position 1 in \"startswith('A','B','C')\" with the specified arguments. Method \"startswith\" requires exact 2 argument(s).");
//CASE 16
- GetPTF("concat()")
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"concat()\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
+ GetPTF("concat()").aExMsgText("No applicable method found for \"concat\" at position 1 in \"concat()\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
//CASE 17
- GetPTF("concat('A')")
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"concat('A')\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
+ GetPTF("concat('A')").aExMsgText("No applicable method found for \"concat\" at position 1 in \"concat('A')\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
//CASE 18
- GetPTF("concat('A','B')")
- .aSerialized("{concat('A','B')}");
+ GetPTF("concat('A','B')").aSerialized("{concat('A','B')}");
//CASE 19
- GetPTF("concat('A','B','C')")
- .aSerialized("{concat('A','B','C')}");
+ GetPTF("concat('A','B','C')").aSerialized("{concat('A','B','C')}");
//CASE 20
- GetPTF("'A' and concat('A')")
- .aExMsgText("No applicable method found for \"concat\" at position 9 in \"'A' and concat('A')\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
+ GetPTF("'A' and concat('A')").aExMsgText("No applicable method found for \"concat\" at position 9 in \"'A' and concat('A')\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
//CASE 1
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=concat(
//-->Expression expected at position 7.
- GetPTF("concat(").aExType(ExpressionParserException.class)
- .aExMsgText("Expression expected after position 7 in \"concat(\".");
+ GetPTF("concat(").aExType(ExpressionParserException.class).aExMsgText("Expression expected after position 7 in \"concat(\".");
//CASE 2
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=concat(123
//-->')' or ',' expected at position 10.
- GetPTF("concat(123").aExType(ExpressionParserException.class)
- .aExMsgText("\")\" or \",\" expected after position 10 in \"concat(123\".");
+ GetPTF("concat(123").aExType(ExpressionParserException.class).aExMsgText("\")\" or \",\" expected after position 10 in \"concat(123\".");
//.aExMsgText("Missing closing parenthesis \")\" for opening parenthesis \"(\" at position 7 in \"concat(\".");
//CASE 3
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=concat(,
//Expression expected at position 7.
- GetPTF("concat(,").aExType(ExpressionParserException.class)
- .aExMsgText("Expression expected at position 8 in \"concat(,\".");
+ GetPTF("concat(,").aExType(ExpressionParserException.class).aExMsgText("Expression expected at position 8 in \"concat(,\".");
//CASE 4
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=concat(123,
//-->Expression expected at position 11.
- GetPTF("concat(123,").aExType(ExpressionParserException.class)
- .aExMsgText("Expression expected after position 11 in \"concat(123,\".");
+ GetPTF("concat(123,").aExType(ExpressionParserException.class).aExMsgText("Expression expected after position 11 in \"concat(123,\".");
//CASE 5
//min = -1, max = -1,
@@ -220,70 +187,55 @@ public class TestParserExceptions extends TestBase {
//CASE 7
//min = 2, max = -1,
- GetPTF("testingMINMAX3()").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX3()\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
- GetPTF("testingMINMAX3('A')").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX3('A')\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
+ GetPTF("testingMINMAX3()").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX3()\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
+ GetPTF("testingMINMAX3('A')").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX3('A')\" with the specified arguments. Method \"concat\" requires 2 or more arguments.");
GetPTF("testingMINMAX3('A','B')").aSerialized("{concat('A','B')}");
GetPTF("testingMINMAX3('A','B','C')").aSerialized("{concat('A','B','C')}");
//CASE 8
//min =-1, max = 0,
GetPTF("testingMINMAX4()").aSerialized("{concat()}");
- GetPTF("testingMINMAX4('A')").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX4('A')\" with the specified arguments. Method \"concat\" requires maximal 0 arguments.");
- GetPTF("testingMINMAX4('A','B')").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX4('A','B')\" with the specified arguments. Method \"concat\" requires maximal 0 arguments.");
- GetPTF("testingMINMAX4('A','B','C')").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX4('A','B','C')\" with the specified arguments. Method \"concat\" requires maximal 0 arguments.");
+ GetPTF("testingMINMAX4('A')").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX4('A')\" with the specified arguments. Method \"concat\" requires maximal 0 arguments.");
+ GetPTF("testingMINMAX4('A','B')").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX4('A','B')\" with the specified arguments. Method \"concat\" requires maximal 0 arguments.");
+ GetPTF("testingMINMAX4('A','B','C')").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX4('A','B','C')\" with the specified arguments. Method \"concat\" requires maximal 0 arguments.");
//CASE 9
//min =-1, max = 2,
GetPTF("testingMINMAX5()").aSerialized("{concat()}");
GetPTF("testingMINMAX5('A')").aSerialized("{concat('A')}");
GetPTF("testingMINMAX5('A','B')").aSerialized("{concat('A','B')}");
- GetPTF("testingMINMAX5('A','B','C')").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX5('A','B','C')\" with the specified arguments. Method \"concat\" requires maximal 2 arguments.");
+ GetPTF("testingMINMAX5('A','B','C')").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX5('A','B','C')\" with the specified arguments. Method \"concat\" requires maximal 2 arguments.");
//CASE 10
// min =1, max = 2,
- GetPTF("testingMINMAX6()").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX6()\" with the specified arguments. Method \"concat\" requires between 1 and 2 arguments.");
+ GetPTF("testingMINMAX6()").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX6()\" with the specified arguments. Method \"concat\" requires between 1 and 2 arguments.");
GetPTF("testingMINMAX6('A')").aSerialized("{concat('A')}");
GetPTF("testingMINMAX6('A','B')").aSerialized("{concat('A','B')}");
- GetPTF("testingMINMAX6('A','B','C')").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX6('A','B','C')\" with the specified arguments. Method \"concat\" requires between 1 and 2 arguments.");
+ GetPTF("testingMINMAX6('A','B','C')").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX6('A','B','C')\" with the specified arguments. Method \"concat\" requires between 1 and 2 arguments.");
//CASE 11
// min =1, max = 2,
- GetPTF("testingMINMAX7()").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX7()\" with the specified arguments. Method \"concat\" requires exact 1 argument(s).");
+ GetPTF("testingMINMAX7()").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX7()\" with the specified arguments. Method \"concat\" requires exact 1 argument(s).");
GetPTF("testingMINMAX7('A')").aSerialized("{concat('A')}");
- GetPTF("testingMINMAX7('A','B')").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX7('A','B')\" with the specified arguments. Method \"concat\" requires exact 1 argument(s).");
- GetPTF("testingMINMAX7('A','B','C')").aExType(ExpressionParserException.class)
- .aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX7('A','B','C')\" with the specified arguments. Method \"concat\" requires exact 1 argument(s).");
+ GetPTF("testingMINMAX7('A','B')").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX7('A','B')\" with the specified arguments. Method \"concat\" requires exact 1 argument(s).");
+ GetPTF("testingMINMAX7('A','B','C')").aExType(ExpressionParserException.class).aExMsgText("No applicable method found for \"concat\" at position 1 in \"testingMINMAX7('A','B','C')\" with the specified arguments. Method \"concat\" requires exact 1 argument(s).");
//CASE 12
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=concat('a' 'b')
//-->')' or ',' expected at position 11.
- GetPTF("concat('a' 'b')")
- .aExMsgText("\")\" or \",\" expected after position 10 in \"concat('a' 'b')\".");
+ GetPTF("concat('a' 'b')").aExMsgText("\")\" or \",\" expected after position 10 in \"concat('a' 'b')\".");
}
@Test
- public void testPMreadParenthesis()
- {
+ public void testPMreadParenthesis() {
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=(123
//-->')' or operator expected at position 4.
- GetPTF("(123").aExType(ExpressionParserException.class)
- .aExMsgText("Missing closing parenthesis \")\" for opening parenthesis \"(\" at position 1 in \"(123\".");
+ GetPTF("(123").aExType(ExpressionParserException.class).aExMsgText("Missing closing parenthesis \")\" for opening parenthesis \"(\" at position 1 in \"(123\".");
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=(123 add (456
//-->')' or operator expected at position 13.
- GetPTF("(123 add (456").aExType(ExpressionParserException.class)
- .aExMsgText("Missing closing parenthesis \")\" for opening parenthesis \"(\" at position 10 in \"(123 add (456\".");
+ GetPTF("(123 add (456").aExType(ExpressionParserException.class).aExMsgText("Missing closing parenthesis \")\" for opening parenthesis \"(\" at position 10 in \"(123 add (456\".");
}
@@ -292,9 +244,7 @@ public class TestParserExceptions extends TestBase {
{
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=123 add 'abc'
//-->Operator 'add' incompatible with operand types 'System.Int32' and 'System.String' at position 4.
- GetPTF("123 add 'abc'").aExType(ExpressionParserException.class)
- .aExKey(ExpressionParserException.INVALID_TYPES_FOR_BINARY_OPERATOR)
- .aExMsgText("Operator \"add\" incompatible with operand types \"System.Uint7\" and \"Edm.String\" at position 5 in \"123 add 'abc'\".");
+ GetPTF("123 add 'abc'").aExType(ExpressionParserException.class).aExKey(ExpressionParserException.INVALID_TYPES_FOR_BINARY_OPERATOR).aExMsgText("Operator \"add\" incompatible with operand types \"System.Uint7\" and \"Edm.String\" at position 5 in \"123 add 'abc'\".");
}
@Test
@@ -304,8 +254,7 @@ public class TestParserExceptions extends TestBase {
//http://services.odata.org/Northwind/Northwind.svc/Products/?$filter=year(327686)
//-->No applicable function found for 'year' at position 0 with the specified arguments. The functions considered are: year(System.DateTime).
String aInt32 = "327686";
- GetPTF("year(" + aInt32 + ")")
- .aExMsgText("No applicable method found for \"year\" at position 1 in \"year(327686)\" for the specified argument types.");
+ GetPTF("year(" + aInt32 + ")").aExMsgText("No applicable method found for \"year\" at position 1 in \"year(327686)\" for the specified argument types.");
}
@Test
@@ -313,106 +262,80 @@ public class TestParserExceptions extends TestBase {
{
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter='123
//-->Unterminated string literal at position 4 in ''123'.
- GetPTF("'123").aExType(ExpressionParserException.class)
- .aExKey(ExpressionParserException.TOKEN_UNDETERMINATED_STRING)
- .aExMsgText("Unterminated string literal at position 1 in \"'123\".");
+ GetPTF("'123").aExType(ExpressionParserException.class).aExKey(ExpressionParserException.TOKEN_UNDETERMINATED_STRING).aExMsgText("Unterminated string literal at position 1 in \"'123\".");
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=1%20add%20'123
//-->Unterminated string literal at position 10 in '1 add '123'.
- GetPTF("1 add '123").aExType(ExpressionParserException.class)
- .aExKey(ExpressionParserException.TOKEN_UNDETERMINATED_STRING)
- .aExMsgText("Unterminated string literal at position 7 in \"1 add '123\".");
+ GetPTF("1 add '123").aExType(ExpressionParserException.class).aExKey(ExpressionParserException.TOKEN_UNDETERMINATED_STRING).aExMsgText("Unterminated string literal at position 7 in \"1 add '123\".");
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=datetime'123
//-->Unterminated literal at position 12 in 'datetime'123'.
- GetPTF("datetime'123").aExType(ExpressionParserException.class)
- .aExKey(ExpressionParserException.TOKEN_UNDETERMINATED_STRING)
- .aExMsgText("Unterminated string literal at position 9 in \"datetime'123\".");
+ GetPTF("datetime'123").aExType(ExpressionParserException.class).aExKey(ExpressionParserException.TOKEN_UNDETERMINATED_STRING).aExMsgText("Unterminated string literal at position 9 in \"datetime'123\".");
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=123%20456
//-->Expression of type 'System.Boolean' expected at position 0.
- GetPTF("123 456").aExType(ExpressionParserException.class)
- .aExKey(ExpressionParserException.INVALID_TRAILING_TOKEN_DETECTED_AFTER_PARSING)
- .aExMsgText("Invalid token \"456\" detected after parsing at position 5 in \"123 456\".");
+ GetPTF("123 456").aExType(ExpressionParserException.class).aExKey(ExpressionParserException.INVALID_TRAILING_TOKEN_DETECTED_AFTER_PARSING).aExMsgText("Invalid token \"456\" detected after parsing at position 5 in \"123 456\".");
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=123%20456
//-->Expression of type 'System.Boolean' expected at position 0.
- GetPTF("123 456 789").aExType(ExpressionParserException.class)
- .aExKey(ExpressionParserException.INVALID_TRAILING_TOKEN_DETECTED_AFTER_PARSING)
- .aExMsgText("Invalid token \"456\" detected after parsing at position 5 in \"123 456 789\".");
+ GetPTF("123 456 789").aExType(ExpressionParserException.class).aExKey(ExpressionParserException.INVALID_TRAILING_TOKEN_DETECTED_AFTER_PARSING).aExMsgText("Invalid token \"456\" detected after parsing at position 5 in \"123 456 789\".");
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=abc%20abc
//-->No property 'abc' exists in type 'ODataWeb.Northwind.Model.Supplier' at position 0.
- GetPTF("abc abc").aExType(ExpressionParserException.class)
- .aExKey(ExpressionParserException.INVALID_TRAILING_TOKEN_DETECTED_AFTER_PARSING)
- .aExMsgText("Invalid token \"abc\" detected after parsing at position 5 in \"abc abc\".");
+ GetPTF("abc abc").aExType(ExpressionParserException.class).aExKey(ExpressionParserException.INVALID_TRAILING_TOKEN_DETECTED_AFTER_PARSING).aExMsgText("Invalid token \"abc\" detected after parsing at position 5 in \"abc abc\".");
}
@Test
- public void testAdditionalStuff()
- {
+ public void testAdditionalStuff() {
- GetPTF("( A mul B )/X eq TEST")
- .aSerialized("{{{A mul B}/X} eq TEST}");
+ GetPTF("( A mul B )/X eq TEST").aSerialized("{{{A mul B}/X} eq TEST}");
- GetPTF("( 1 mul 2 )/X eq TEST")
- .aSerialized("{{{1 mul 2}/X} eq TEST}");
+ GetPTF("( 1 mul 2 )/X eq TEST").aSerialized("{{{1 mul 2}/X} eq TEST}");
//CASE 1
EdmEntityType edmEtAllTypes = edmInfo.getTypeEtAllTypes();
- GetPTF(edmEtAllTypes, "( 1 mul 2 )/X eq TEST")
- .aExMsgText("Leftside of method operator at position 12 is not a property in \"( 1 mul 2 )/X eq TEST\".");
+ GetPTF(edmEtAllTypes, "( 1 mul 2 )/X eq TEST").aExMsgText("Leftside of method operator at position 12 is not a property in \"( 1 mul 2 )/X eq TEST\".");
//CASE 2
//http://services.odata.org/Northwind/Northwind.svc/Products/?$filter=notsupportedfunction('a')
//-->Unknown function 'notsupportedfunction' at position 0.
- GetPTF("notsupportedfunction('a')")
- .aExMsgText("Unknown function \"notsupportedfunction\" at position 1 in \"notsupportedfunction('a')\".");
+ GetPTF("notsupportedfunction('a')").aExMsgText("Unknown function \"notsupportedfunction\" at position 1 in \"notsupportedfunction('a')\".");
//CASE 3
//http://services.odata.org/Northwind/Northwind.svc/Products/?$filter=notsupportedfunction('a')
//-->Unknown function 'notsupportedfunction' at position 0.
- GetPTF("notsupportedfunction ('a')")
- .aExMsgText("Unknown function \"notsupportedfunction\" at position 1 in \"notsupportedfunction ('a')\".");
+ GetPTF("notsupportedfunction ('a')").aExMsgText("Unknown function \"notsupportedfunction\" at position 1 in \"notsupportedfunction ('a')\".");
//CASE 4
//Use \ instead of /
- GetPTF("Address\\NotAProperty")
- .aExMsgText("Error while tokenizing a ODATA expression on token \"\\\" at position 8 in \"Address\\NotAProperty\".");
+ GetPTF("Address\\NotAProperty").aExMsgText("Error while tokenizing a ODATA expression on token \"\\\" at position 8 in \"Address\\NotAProperty\".");
//CASE 5
- GetPTF("-(-(- 2d)))")
- .aExMsgText("Invalid token \")\" detected after parsing at position 11 in \"-(-(- 2d)))\".");
+ GetPTF("-(-(- 2d)))").aExMsgText("Invalid token \")\" detected after parsing at position 11 in \"-(-(- 2d)))\".");
//CASE 6
- GetPTF("a b")
- .aExMsgText("Invalid token \"b\" detected after parsing at position 3 in \"a b\".");
+ GetPTF("a b").aExMsgText("Invalid token \"b\" detected after parsing at position 3 in \"a b\".");
//CASE 7
- GetPTF("a eq b b")
- .aExMsgText("Invalid token \"b\" detected after parsing at position 8 in \"a eq b b\".");
+ GetPTF("a eq b b").aExMsgText("Invalid token \"b\" detected after parsing at position 8 in \"a eq b b\".");
//CASE 8
- GetPTF(edmEtAllTypes, "year(Complex)")
- .aExMsgText("No applicable method found for \"year\" at position 1 in \"year(Complex)\" for the specified argument types.");
+ GetPTF(edmEtAllTypes, "year(Complex)").aExMsgText("No applicable method found for \"year\" at position 1 in \"year(Complex)\" for the specified argument types.");
//CASE 9
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=1%20add%202
//-->Expression of type 'System.Boolean' expected at position 0.
- GetPTF_onlyBinary("1 add 2")
- .aExMsgText("Expression of type \"Edm.Boolean\" expected at position 1 in \"1 add 2\" (actual type is \"Edm.SByte\").");
+ GetPTF_onlyBinary("1 add 2").aExMsgText("Expression of type \"Edm.Boolean\" expected at position 1 in \"1 add 2\" (actual type is \"Edm.SByte\").");
//CASE 10
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=1%20add
//-->Expression expected at position 5.
- GetPTF_onlyBinary("1 add")
- .aExMsgText("Expression expected after position 5 in \"1 add\".");
+ GetPTF_onlyBinary("1 add").aExMsgText("Expression expected after position 5 in \"1 add\".");
//CASE 11
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=1%20add
//-->Expression expected at position 5.
- GetPTF_onlyBinary("1 add ")
- .aExMsgText("Expression expected after position 5 in \"1 add \".");
+ GetPTF_onlyBinary("1 add ").aExMsgText("Expression expected after position 5 in \"1 add \".");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestSpec.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestSpec.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestSpec.java
index 6b0e48f..3c7b6ba 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestSpec.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestSpec.java
@@ -20,8 +20,6 @@ package org.apache.olingo.odata2.core.uri.expression;
import static org.junit.Assert.fail;
-import org.junit.Test;
-
import org.apache.olingo.odata2.api.edm.EdmComplexType;
import org.apache.olingo.odata2.api.edm.EdmEntityType;
import org.apache.olingo.odata2.api.edm.EdmException;
@@ -46,12 +44,12 @@ import org.apache.olingo.odata2.core.edm.EdmString;
import org.apache.olingo.odata2.core.edm.EdmTime;
import org.apache.olingo.odata2.core.edm.Uint7;
import org.apache.olingo.odata2.core.edm.provider.EdmComplexPropertyImplProv;
+import org.junit.Test;
/**
*
*/
-public class TestSpec extends TestBase
-{
+public class TestSpec extends TestBase {
final static String aBoolean = "true";
final static String aBinary = "binary'FA12AAA1'";
final static String aBit = "1";
@@ -89,8 +87,7 @@ public class TestSpec extends TestBase
final EdmTime timeInst = EdmTime.getInstance();
@Test
- public void testMinimumSpecReq()
- {
+ public void testMinimumSpecReq() {
//ADD
GetPTF(aDecimal + " add " + aDecimal).aEdmType(decimalInst).aSerialized("{" + aDecimal + " add " + aDecimal + "}");
@@ -284,8 +281,7 @@ public class TestSpec extends TestBase
}
@Test
- public void testPropertiesWithEdm()
- {
+ public void testPropertiesWithEdm() {
try {
EdmEntityType edmEtAllTypes = edmInfo.getTypeEtAllTypes();
EdmProperty string = (EdmProperty) edmEtAllTypes.getProperty("String");
@@ -301,30 +297,16 @@ public class TestSpec extends TestBase
GetPTF(edmEtAllTypes, "String").aEdmProperty(string).aEdmType(stringType);
- GetPTF(edmEtAllTypes, "'text' eq String")
- .root().aKind(ExpressionKind.BINARY);
+ GetPTF(edmEtAllTypes, "'text' eq String").root().aKind(ExpressionKind.BINARY);
- GetPTF(edmEtAllTypes, "Complex/String")
- .root().left().aEdmProperty(complex).aEdmType(complexType)
- .root().right().aEdmProperty(complexString).aEdmType(complexStringType)
- .root().aKind(ExpressionKind.MEMBER).aEdmType(complexStringType);
+ GetPTF(edmEtAllTypes, "Complex/String").root().left().aEdmProperty(complex).aEdmType(complexType).root().right().aEdmProperty(complexString).aEdmType(complexStringType).root().aKind(ExpressionKind.MEMBER).aEdmType(complexStringType);
- GetPTF(edmEtAllTypes, "Complex/Address/City")
- .root().aKind(ExpressionKind.MEMBER)
- .root().left().aKind(ExpressionKind.MEMBER)
- .root().left().left().aKind(ExpressionKind.PROPERTY).aEdmProperty(complex).aEdmType(complexType)
- .root().left().right().aKind(ExpressionKind.PROPERTY).aEdmProperty(complexAddress).aEdmType(complexAddressType)
- .root().left().aEdmType(complexAddressType)
- .root().right().aKind(ExpressionKind.PROPERTY).aEdmProperty(complexAddressCity).aEdmType(complexAddressCityType)
- .root().aEdmType(complexAddressCityType);
+ GetPTF(edmEtAllTypes, "Complex/Address/City").root().aKind(ExpressionKind.MEMBER).root().left().aKind(ExpressionKind.MEMBER).root().left().left().aKind(ExpressionKind.PROPERTY).aEdmProperty(complex).aEdmType(complexType).root().left().right().aKind(ExpressionKind.PROPERTY).aEdmProperty(complexAddress).aEdmType(complexAddressType).root().left().aEdmType(complexAddressType).root().right().aKind(ExpressionKind.PROPERTY).aEdmProperty(complexAddressCity).aEdmType(complexAddressCityType).root().aEdmType(complexAddressCityType);
EdmProperty boolean_ = (EdmProperty) edmEtAllTypes.getProperty("Boolean");
EdmSimpleType boolean_Type = (EdmSimpleType) boolean_.getType();
- GetPTF(edmEtAllTypes, "not Boolean")
- .aKind(ExpressionKind.UNARY)
- .aEdmType(boolean_Type)
- .right().aEdmProperty(boolean_).aEdmType(boolean_Type);
+ GetPTF(edmEtAllTypes, "not Boolean").aKind(ExpressionKind.UNARY).aEdmType(boolean_Type).right().aEdmProperty(boolean_).aEdmType(boolean_Type);
} catch (EdmException e) {
fail("Error in testPropertiesWithEdm:" + e.getLocalizedMessage());
@@ -333,8 +315,7 @@ public class TestSpec extends TestBase
}
@Test
- public void testDeepParenthesis()
- {
+ public void testDeepParenthesis() {
GetPTF("2d").aSerialized("2d");
GetPTF("(2d)").aSerialized("2d");
GetPTF("((2d))").aSerialized("2d");
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestTokenizer.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestTokenizer.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestTokenizer.java
index 390ced0..58990b9 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestTokenizer.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TestTokenizer.java
@@ -25,110 +25,61 @@ import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
-public class TestTokenizer
-{
+public class TestTokenizer {
@Test
- public void tokenizeWhiteSpaces() throws Exception
- {
+ public void tokenizeWhiteSpaces() throws Exception {
//space
- getTTW(" ")
- .at(0)
- .aKind(TokenKind.WHITESPACE)
- .aUriLiteral(" ")
- .aPosition(0);
-
- getTTW(" ")
- .at(0)
- .aKind(TokenKind.WHITESPACE)
- .aUriLiteral(" ")
- .aPosition(0);
-
- getTTW("A ")
- .at(1)
- .aKind(TokenKind.WHITESPACE)
- .aUriLiteral(" ")
- .aPosition(1);
-
- getTTW(" B")
- .at(0)
- .aKind(TokenKind.WHITESPACE)
- .aUriLiteral(" ")
- .aPosition(0);
-
- getTTW("A B")
- .at(1)
- .aKind(TokenKind.WHITESPACE)
- .aUriLiteral(" ")
- .aPosition(1)
- .at(2)
- .aKind(TokenKind.LITERAL)
- .aUriLiteral("B")
- .aPosition(4);
-
- getTTW("A B C")
- .at(3)
- .aKind(TokenKind.WHITESPACE)
- .aUriLiteral(" ")
- .aPosition(5);
+ getTTW(" ").at(0).aKind(TokenKind.WHITESPACE).aUriLiteral(" ").aPosition(0);
+
+ getTTW(" ").at(0).aKind(TokenKind.WHITESPACE).aUriLiteral(" ").aPosition(0);
+
+ getTTW("A ").at(1).aKind(TokenKind.WHITESPACE).aUriLiteral(" ").aPosition(1);
+
+ getTTW(" B").at(0).aKind(TokenKind.WHITESPACE).aUriLiteral(" ").aPosition(0);
+
+ getTTW("A B").at(1).aKind(TokenKind.WHITESPACE).aUriLiteral(" ").aPosition(1).at(2).aKind(TokenKind.LITERAL).aUriLiteral("B").aPosition(4);
+
+ getTTW("A B C").at(3).aKind(TokenKind.WHITESPACE).aUriLiteral(" ").aPosition(5);
}
@Test
- public void tokenizeSymbols() throws Exception
- {
+ public void tokenizeSymbols() throws Exception {
//parentheses
getTT("(").aKind(TokenKind.OPENPAREN).aUriLiteral("(");
- getTT("abc(")
- .at(1)
- .aKind(TokenKind.OPENPAREN).aUriLiteral("(")
- .aPosition(3);
+ getTT("abc(").at(1).aKind(TokenKind.OPENPAREN).aUriLiteral("(").aPosition(3);
getTT(")").aKind(TokenKind.CLOSEPAREN).aUriLiteral(")");
- getTT("abc)")
- .at(1)
- .aKind(TokenKind.CLOSEPAREN).aUriLiteral(")")
- .aPosition(3);
+ getTT("abc)").at(1).aKind(TokenKind.CLOSEPAREN).aUriLiteral(")").aPosition(3);
//symbol
getTT(",").aKind(TokenKind.COMMA).aUriLiteral(",");
- getTT("abc,")
- .at(1)
- .aKind(TokenKind.COMMA).aUriLiteral(",")
- .aPosition(3);
+ getTT("abc,").at(1).aKind(TokenKind.COMMA).aUriLiteral(",").aPosition(3);
//minus
getTT("-").aKind(TokenKind.SYMBOL).aUriLiteral("-");
- getTT("abc -")
- .at(1)
- .aKind(TokenKind.SYMBOL).aUriLiteral("-")
- .aPosition(4);
+ getTT("abc -").at(1).aKind(TokenKind.SYMBOL).aUriLiteral("-").aPosition(4);
//minus after literal belongs to literal
- getTT("abc-")
- .at(0)
- .aKind(TokenKind.LITERAL).aUriLiteral("abc-")
- .aPosition(0);
+ getTT("abc-").at(0).aKind(TokenKind.LITERAL).aUriLiteral("abc-").aPosition(0);
}
- public static String HexToBase64(final String hex)
- {
+ public static String HexToBase64(final String hex) {
String base64 = "";
byte bArr[];
try {
bArr = Hex.decodeHex(hex.toCharArray());
base64 = Base64.encodeBase64String(bArr);
- } catch (DecoderException e)
- {
+ } catch (DecoderException e) {
fail("Error in Unittest preparation ( HEX->base64");
}
return base64;
}
@Test
- public void tokenizeTypes() throws Exception
- {
+ public void tokenizeTypes() throws Exception {
getTT("a").aKind(TokenKind.LITERAL).aUriLiteral("a").aPosition(0);
getTT("abc a").at(1).aKind(TokenKind.LITERAL).aUriLiteral("a").aPosition(4);
@@ -153,56 +104,40 @@ public class TestTokenizer
}
@Test
- public void tokenizeOperators() throws Exception
- {
+ public void tokenizeOperators() throws Exception {
getTT("a eq b").at(1).aKind(TokenKind.LITERAL).aUriLiteral("eq");
getTT("a eqotto b").at(1).aKind(TokenKind.LITERAL).aUriLiteral("eqotto");
}
@Test
- public void testExceptions() throws Exception
- {
+ public void testExceptions() throws Exception {
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter='a
//-->Unterminated string literal at position 2 in ''a'.
- getTT("'a")
- .aExMsgText("Unterminated string literal at position 1 in \"'a\".");
+ getTT("'a").aExMsgText("Unterminated string literal at position 1 in \"'a\".");
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=X'g'
//-->Unrecognized 'Edm.Binary' literal 'X'g'' in '0'.
- getTT("X'g'")
- .aExMsgText("Type detection error for string like token 'X'g'' at position '1'.");
+ getTT("X'g'").aExMsgText("Type detection error for string like token 'X'g'' at position '1'.");
//http://services.odata.org/Northwind/Northwind.svc/Products(1)/Supplier?$filter=\
//-->Syntax error '\' at position 0.
- getTT("\\")
- .aExMsgText("Unknown character '\\' at position '0' detected in \"\\\".");
+ getTT("\\").aExMsgText("Unknown character '\\' at position '0' detected in \"\\\".");
}
@Test
- public void tokenizeFunction() throws Exception
- {
- getTT("substringof('10')")
- .at(0).aKind(TokenKind.LITERAL).aUriLiteral("substringof")
- .at(2).aKind(TokenKind.SIMPLE_TYPE).aUriLiteral("'10'");
-
- getTT("substringof ( '10' ) ")
- .at(0).aKind(TokenKind.LITERAL).aUriLiteral("substringof")
- .at(2).aKind(TokenKind.SIMPLE_TYPE).aUriLiteral("'10'");
+ public void tokenizeFunction() throws Exception {
+ getTT("substringof('10')").at(0).aKind(TokenKind.LITERAL).aUriLiteral("substringof").at(2).aKind(TokenKind.SIMPLE_TYPE).aUriLiteral("'10'");
+
+ getTT("substringof ( '10' ) ").at(0).aKind(TokenKind.LITERAL).aUriLiteral("substringof").at(2).aKind(TokenKind.SIMPLE_TYPE).aUriLiteral("'10'");
}
@Test
- public void testEx1111ceptions() throws Exception
- {
- getTT("a 1")
- .at(0).aKind(TokenKind.LITERAL).aUriLiteral("a")
- .at(1).aKind(TokenKind.SIMPLE_TYPE).aUriLiteral("1");
+ public void testEx1111ceptions() throws Exception {
+ getTT("a 1").at(0).aKind(TokenKind.LITERAL).aUriLiteral("a").at(1).aKind(TokenKind.SIMPLE_TYPE).aUriLiteral("1");
- getTT("a eq b").at(0).aKind(TokenKind.LITERAL).aUriLiteral("a")
- .at(1).aKind(TokenKind.LITERAL).aUriLiteral("eq")
- .at(2).aKind(TokenKind.LITERAL).aUriLiteral("b");
+ getTT("a eq b").at(0).aKind(TokenKind.LITERAL).aUriLiteral("a").at(1).aKind(TokenKind.LITERAL).aUriLiteral("eq").at(2).aKind(TokenKind.LITERAL).aUriLiteral("b");
- getTT("start_date eq datetime'2011-01-12T00:00:00' and end_date eq datetime'2011-12-31T00:00:00'")
- .at(2).aUriLiteral("datetime'2011-01-12T00:00:00'");
+ getTT("start_date eq datetime'2011-01-12T00:00:00' and end_date eq datetime'2011-12-31T00:00:00'").at(2).aUriLiteral("datetime'2011-01-12T00:00:00'");
getTT("'a%b'").at(0).aKind(TokenKind.SIMPLE_TYPE).aUriLiteral("'a%b'");
@@ -212,8 +147,7 @@ public class TestTokenizer
* Create TokenTool ( and Token list) without respecting whitespaces
* @param expression Expression to be tokenized
*/
- public TokenTool getTT(final String expression)
- {
+ public TokenTool getTT(final String expression) {
return new TokenTool(expression, false);
}
@@ -221,8 +155,7 @@ public class TestTokenizer
* Create TokenTool ( and Token list) without respecting whitespaces
* @param expression Expression to be tokenized
*/
- public TokenTool getTTW(final String expression)
- {
+ public TokenTool getTTW(final String expression) {
return new TokenTool(expression, true);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TokenTool.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TokenTool.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TokenTool.java
index ac1e0b7..a1c714b 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TokenTool.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/TokenTool.java
@@ -23,17 +23,15 @@ import static org.junit.Assert.fail;
import java.util.Locale;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.apache.olingo.odata2.api.exception.MessageReference;
import org.apache.olingo.odata2.api.exception.ODataMessageException;
import org.apache.olingo.odata2.api.uri.expression.ExpressionParserException;
import org.apache.olingo.odata2.core.exception.MessageService;
import org.apache.olingo.odata2.core.exception.MessageService.Message;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public class TokenTool
-{
+public class TokenTool {
protected Token token;
protected TokenList tokens = null;
private Exception curException;
@@ -44,8 +42,7 @@ public class TokenTool
private static final Logger log = LoggerFactory.getLogger(ParserTool.class);
private static final Locale DEFAULT_LANGUAGE = new Locale("test", "SAP");
- public TokenTool(final String expression, final boolean wsp)
- {
+ public TokenTool(final String expression, final boolean wsp) {
dout("TokenTool - Testing: " + expression);
this.expression = expression;
@@ -69,8 +66,7 @@ public class TokenTool
* @return Returns <code>this</code>
* @throws AssertionError
*/
- public TokenTool at(final int index)
- {
+ public TokenTool at(final int index) {
token = tokens.elementAt(index);
return this;
}
@@ -82,8 +78,7 @@ public class TokenTool
* @return Returns <code>this</code>
* @throws AssertionError
*/
- public TokenTool aKind(final TokenKind kind)
- {
+ public TokenTool aKind(final TokenKind kind) {
assertEquals(kind, token.getKind());
return this;
}
@@ -95,8 +90,7 @@ public class TokenTool
* @return Returns <code>this</code>
* @throws AssertionError
*/
- public TokenTool aEdmType(final int edmType)
- {
+ public TokenTool aEdmType(final int edmType) {
assertEquals(edmType, token.getEdmType());
return this;
}
@@ -108,27 +102,23 @@ public class TokenTool
* @return Returns <code>this</code>
* @throws AssertionError
*/
- public TokenTool aUriLiteral(final String stringValue)
- {
+ public TokenTool aUriLiteral(final String stringValue) {
assertEquals(stringValue, token.getUriLiteral());
return this;
}
- public TokenTool aPosition(final int position)
- {
+ public TokenTool aPosition(final int position) {
assertEquals(position, token.getPosition());
return this;
}
- public static void dout(final String out)
- {
+ public static void dout(final String out) {
if (debug) {
log.debug(out);
}
}
- public static void out(final String out)
- {
+ public static void out(final String out) {
log.debug(out);
}
@@ -136,21 +126,17 @@ public class TokenTool
* Verifies that all place holders in the message text definition of the thrown exception are provided with content
* @return TokenTool
*/
- public TokenTool aExMsgContentAllSet()
- {
+ public TokenTool aExMsgContentAllSet() {
String info = "aExMessageTextNoEmptyTag(" + expression + ")-->";
- if (curException == null)
- {
+ if (curException == null) {
fail("Error in aExMessageText: Expected exception.");
}
ODataMessageException messageException;
- try
- {
+ try {
messageException = (ODataMessageException) curException;
- } catch (ClassCastException ex)
- {
+ } catch (ClassCastException ex) {
fail("Error in aExNext: curException not an ODataMessageException");
return this;
}
@@ -160,8 +146,7 @@ public class TokenTool
dout(info);
- if (ms.getText().contains("[%"))
- {
+ if (ms.getText().contains("[%")) {
fail(info);
}
return this;
@@ -171,21 +156,17 @@ public class TokenTool
* Verifies that the message text of the thrown exception is not empty
* @return TokenTool
*/
- public TokenTool aExMsgNotEmpty()
- {
+ public TokenTool aExMsgNotEmpty() {
String info = "aExTextNotEmpty(" + expression + ")-->";
- if (curException == null)
- {
+ if (curException == null) {
fail("Error in aExMessageText: Expected exception.");
}
ODataMessageException messageException;
- try
- {
+ try {
messageException = (ODataMessageException) curException;
- } catch (ClassCastException ex)
- {
+ } catch (ClassCastException ex) {
fail("Error in aExNext: curException not an ODataMessageException");
return this;
}
@@ -194,30 +175,25 @@ public class TokenTool
info = " " + info + "check if Messagetext is empty";
dout(info);
- if (ms.getText().length() == 0)
- {
+ if (ms.getText().length() == 0) {
fail(info);
}
return this;
}
- public TokenTool aExKey(final MessageReference expressionExpectedAtPos)
- {
+ public TokenTool aExKey(final MessageReference expressionExpectedAtPos) {
String expectedKey = expressionExpectedAtPos.getKey();
ODataMessageException messageException;
String info = "GetExceptionType(" + expression + ")-->";
- if (curException == null)
- {
+ if (curException == null) {
fail("Error in aExType: Expected exception");
}
- try
- {
+ try {
messageException = (ODataMessageException) curException;
- } catch (ClassCastException ex)
- {
+ } catch (ClassCastException ex) {
fail("Error in aExNext: curException not an ODataMessageException");
return this;
}
@@ -225,27 +201,22 @@ public class TokenTool
String actualKey = messageException.getMessageReference().getKey();
dout(" " + info + "Expected key: " + expectedKey + " Actual: " + actualKey);
- if (expectedKey != actualKey)
- {
+ if (expectedKey != actualKey) {
fail(" " + info + "Expected: " + expectedKey + " Actual: " + actualKey);
}
return this;
}
- public TokenTool printExMessage()
- {
+ public TokenTool printExMessage() {
ODataMessageException messageException;
- if (curException == null)
- {
+ if (curException == null) {
fail("Error in aExMsgPrint: Expected exception");
}
- try
- {
+ try {
messageException = (ODataMessageException) curException;
- } catch (ClassCastException ex)
- {
+ } catch (ClassCastException ex) {
fail("Error in aExNext: curException not an ODataMessageException");
return this;
}
@@ -264,21 +235,17 @@ public class TokenTool
* Expected message text
* @return this
*/
- public TokenTool aExMsgText(final String messageText)
- {
+ public TokenTool aExMsgText(final String messageText) {
String info = "aExMessageText(" + expression + ")-->";
- if (curException == null)
- {
+ if (curException == null) {
fail("Error in aExMessageText: Expected exception.");
}
ODataMessageException messageException;
- try
- {
+ try {
messageException = (ODataMessageException) curException;
- } catch (ClassCastException ex)
- {
+ } catch (ClassCastException ex) {
fail("Error in aExNext: curException not an ODataMessageException");
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/VisitorTool.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/VisitorTool.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/VisitorTool.java
index f8386d6..68a4312 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/VisitorTool.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/uri/expression/VisitorTool.java
@@ -40,8 +40,7 @@ import org.apache.olingo.odata2.api.uri.expression.UnaryOperator;
public class VisitorTool implements ExpressionVisitor {
@Override
- public Object visitBinary(final BinaryExpression binaryExpression, final BinaryOperator operator, final Object leftSide, final Object rightSide)
- {
+ public Object visitBinary(final BinaryExpression binaryExpression, final BinaryOperator operator, final Object leftSide, final Object rightSide) {
return "{" + leftSide.toString() + " " + operator.toUriLiteral() + " " + rightSide.toString() + "}";
}
@@ -51,21 +50,18 @@ public class VisitorTool implements ExpressionVisitor {
}
@Override
- public Object visitLiteral(final LiteralExpression literal, final EdmLiteral edmLiteral)
- {
+ public Object visitLiteral(final LiteralExpression literal, final EdmLiteral edmLiteral) {
return "" + literal.getUriLiteral() + "";
}
@Override
- public Object visitMethod(final MethodExpression methodExpression, final MethodOperator method, final List<Object> retParameters)
- {
+ public Object visitMethod(final MethodExpression methodExpression, final MethodOperator method, final List<Object> retParameters) {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append(method.toUriLiteral());
sb.append("(");
- for (int i = 0; i < retParameters.size(); i++)
- {
+ for (int i = 0; i < retParameters.size(); i++) {
if (i != 0) {
sb.append(",");
}
@@ -78,33 +74,28 @@ public class VisitorTool implements ExpressionVisitor {
}
@Override
- public Object visitMember(final MemberExpression memberExpression, final Object source, final Object path)
- {
+ public Object visitMember(final MemberExpression memberExpression, final Object source, final Object path) {
return "{" + source.toString() + "/" + path.toString() + "}";
}
@Override
- public Object visitProperty(final PropertyExpression literal, final String uriLiteral, final EdmTyped edmProperty)
- {
+ public Object visitProperty(final PropertyExpression literal, final String uriLiteral, final EdmTyped edmProperty) {
return uriLiteral;
}
@Override
- public Object visitUnary(final UnaryExpression unaryExpression, final UnaryOperator operator, final Object operand)
- {
+ public Object visitUnary(final UnaryExpression unaryExpression, final UnaryOperator operator, final Object operand) {
return "{" + operator.toUriLiteral() + " " + operand.toString() + "}";
}
@Override
- public Object visitOrderByExpression(final OrderByExpression orderByExpression, final String expressionString, final List<Object> orders)
- {
+ public Object visitOrderByExpression(final OrderByExpression orderByExpression, final String expressionString, final List<Object> orders) {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("oc");
sb.append("(");
- for (int i = 0; i < orders.size(); i++)
- {
+ for (int i = 0; i < orders.size(); i++) {
if (i != 0) {
sb.append(",");
}
@@ -117,8 +108,7 @@ public class VisitorTool implements ExpressionVisitor {
}
@Override
- public Object visitOrder(final OrderExpression orderExpression, final Object filterResult, final SortOrder sortOrder)
- {
+ public Object visitOrder(final OrderExpression orderExpression, final Object filterResult, final SortOrder sortOrder) {
return "{o(" + filterResult + ", " + sortOrder.toString() + ")}";
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/helper/ODataMessageTextVerifier.java
----------------------------------------------------------------------
diff --git a/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/helper/ODataMessageTextVerifier.java b/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/helper/ODataMessageTextVerifier.java
index 3a1339e..1c0816a 100644
--- a/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/helper/ODataMessageTextVerifier.java
+++ b/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/helper/ODataMessageTextVerifier.java
@@ -75,8 +75,7 @@ public class ODataMessageTextVerifier {
private void assertExistMessage(final MessageReference msgRef) {
final String text = getMessage(msgRef);
- if (text == null)
- {
+ if (text == null) {
return; // checked in getMessage
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/1e5280b7/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/mock/TecEdmInfo.java
----------------------------------------------------------------------
diff --git a/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/mock/TecEdmInfo.java b/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/mock/TecEdmInfo.java
index af1aed2..acaf2ad 100644
--- a/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/mock/TecEdmInfo.java
+++ b/odata-testutil/src/main/java/org/apache/olingo/odata2/testutil/mock/TecEdmInfo.java
@@ -28,8 +28,7 @@ import org.apache.olingo.odata2.api.edm.EdmException;
* Helper for the entity data model used as technical reference scenario.
*
*/
-public class TecEdmInfo
-{
+public class TecEdmInfo {
private final Edm edm;
public TecEdmInfo(final Edm edm) {
@@ -38,10 +37,7 @@ public class TecEdmInfo
public EdmEntityType getTypeEtAllTypes() {
try {
- return edm
- .getEntityContainer(TechnicalScenarioEdmProvider.ENTITY_CONTAINER_1)
- .getEntitySet(TechnicalScenarioEdmProvider.ES_ALL_TYPES)
- .getEntityType();
+ return edm.getEntityContainer(TechnicalScenarioEdmProvider.ENTITY_CONTAINER_1).getEntitySet(TechnicalScenarioEdmProvider.ES_ALL_TYPES).getEntityType();
} catch (final EdmException e) {
fail("Error in test setup" + e.getLocalizedMessage());
}