[OLINGO-603] Further refactoring

This commit is contained in:
Christian Amend 2015-04-01 14:23:26 +02:00
parent ef6ed4e3ef
commit d067037f40
26 changed files with 161 additions and 149 deletions

View File

@ -277,7 +277,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
/**
* Gets the current ETag defined into the wrapped entity.
*
* @return
* @return the current etag
*/
public String getETag() {
return getEntity().getETag();

View File

@ -1463,7 +1463,7 @@ public abstract class AbstractServices {
* @param path
* @param format
* @param changes
* @return
* @return response
*/
@PUT
@Path("/{entitySetName}({entityId})/{path:.*}/$value")
@ -1491,7 +1491,7 @@ public abstract class AbstractServices {
* @param path
* @param format
* @param changes
* @return
* @return response
*/
@MERGE
@Path("/{entitySetName}({entityId})/{path:.*}")
@ -1519,7 +1519,7 @@ public abstract class AbstractServices {
* @param path
* @param format
* @param changes
* @return
* @return response
*/
@PATCH
@Path("/{entitySetName}({entityId})/{path:.*}")
@ -1587,7 +1587,7 @@ public abstract class AbstractServices {
* @param path
* @param format
* @param changes
* @return
* @return response
*/
@PUT
@Path("/{entitySetName}({entityId})/{path:.*}")
@ -1650,7 +1650,7 @@ public abstract class AbstractServices {
* @param entityId
* @param path
* @param format
* @return
* @return response
*/
@DELETE
@Path("/{entitySetName}({entityId})/{path:.*}/$value")

View File

@ -28,9 +28,7 @@ import org.apache.olingo.commons.api.http.HttpMethod;
/**
* Abstract representation of an OData request. Get instance by using factories.
*
* @see org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory
* @see org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory
* @see org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory
* @see org.apache.olingo.client.api.communication.request.batch.BatchRequestFactory
* @see org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory
*/

View File

@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -28,12 +28,12 @@ import org.apache.olingo.client.api.communication.response.ODataReferenceAddingR
* ODataReferenceAdding requests eighter add or change the reference of navigation properties.
*
* If the navigation property is a collection of navigation references, the request adds a new reference to the
* collection. [OData Protocol 4.0 - 11.4.6.1]
* collection. [OData Protocol 4.0 - 11.4.6.1]
*
* If the request addresses an navigation property, which references a single entity, the reference will
* be changed to the value provided by the request. [OData-Protocol 4.0 - 11.4.6.3]
*/
public interface ODataReferenceAddingRequest
extends ODataBasicRequest<ODataReferenceAddingResponse>, ODataBatchableRequest {
public interface ODataReferenceAddingRequest extends ODataBasicRequest<ODataReferenceAddingResponse>,
ODataBatchableRequest {
//No additional methods needed for now.
}

View File

@ -25,7 +25,7 @@ import org.apache.olingo.client.api.communication.request.batch.ODataBatchRespon
/**
* This class implements a response to a batch request.
*
* @see org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest
* @see org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest
*/
public interface ODataBatchResponse extends ODataResponse {

View File

@ -25,7 +25,7 @@ package org.apache.olingo.client.api.communication.response;
* If the request was successful, the service response has status code 204 and
* the body has to be empty.
*
* @see org.apache.olingo.client.api.communication.request.cud.api.request.cud.v4.ODataReferenceAddingRequest
* @see org.apache.olingo.client.api.communication.request.cud.ODataReferenceAddingRequest
*/
public interface ODataReferenceAddingResponse extends ODataResponse {
//No additional methods needed for now.

View File

@ -175,7 +175,7 @@ public interface URIBuilder {
* @return current URIBuilder instance
* @see QueryOption#FILTER
* @see URIFilter
* @see org.apache.olingo.client.api.uri.CommonFilterFactory
* @see org.apache.olingo.client.api.uri.FilterFactory
*/
URIBuilder filter(URIFilter filter);

View File

@ -21,7 +21,7 @@ package org.apache.olingo.client.api.uri;
/**
* Interface for any available filter; obtain instances via <tt>FilterFactory</tt>.
*
* @see org.apache.olingo.client.api.uri.CommonFilterFactory
* @see org.apache.olingo.client.api.uri.FilterFactory
*/
public interface URIFilter {

View File

@ -47,9 +47,7 @@ import org.apache.olingo.commons.api.http.HttpMethod;
/**
* Abstract representation of an OData request. Get instance by using factories.
*
* @see org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory
* @see org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory
* @see org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory
* @see org.apache.olingo.client.api.communication.request.batch.BatchRequestFactory
* @see org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory
*/

View File

@ -23,7 +23,7 @@ import org.apache.olingo.client.api.uri.FilterArg;
/**
* Filter property path; obtain instances via <tt>FilterArgFactory</tt>.
*
* @see org.apache.olingo.client.api.uri.CommonFilterArgFactory
* @see org.apache.olingo.client.api.uri.FilterArgFactory
*/
public class FilterConst implements FilterArg {

View File

@ -23,7 +23,7 @@ import org.apache.olingo.client.api.uri.FilterArg;
/**
* Filter value literals; obtain instances via <tt>FilterArgFactory</tt>.
*
* @see org.apache.olingo.client.api.uri.v3.FilterArgFactory
* @see org.apache.olingo.client.api.uri.FilterArgFactory
*/
public class FilterLiteral implements FilterArg {

View File

@ -23,7 +23,7 @@ import org.apache.olingo.client.api.uri.FilterArg;
/**
* Filter property path; obtain instances via <tt>FilterArgFactory</tt>.
*
* @see org.apache.olingo.client.api.uri.CommonFilterArgFactory
* @see org.apache.olingo.client.api.uri.FilterArgFactory
*/
public class FilterProperty implements FilterArg {

View File

@ -179,7 +179,6 @@ public final class URIUtils {
/**
* Turns primitive values into their respective URI representation.
*
* @param version OData protocol version
* @param obj primitive value
* @return URI representation
*/

View File

@ -23,7 +23,6 @@ import java.util.Map;
/**
* OData complex property value.
*
* @param <OP> The actual ODataProperty interface.
*/
public interface ODataComplexValue extends ODataValue, ODataLinked, ODataAnnotatable, Iterable<ODataProperty> {

View File

@ -30,7 +30,6 @@ public class ODataInlineEntity extends ODataLink {
/**
* Constructor.
*
* @param version OData service version.
* @param uri edit link.
* @param type type.
* @param title title.
@ -45,7 +44,6 @@ public class ODataInlineEntity extends ODataLink {
/**
* Constructor.
*
* @param version OData service version.
* @param baseURI base URI.
* @param href href.
* @param type type.

View File

@ -105,7 +105,6 @@ public class ODataLink extends ODataItem implements ODataAnnotatable {
/**
* Constructor.
*
* @param version OData service version.
* @param uri URI.
* @param type type.
* @param title title.

View File

@ -73,7 +73,6 @@ public enum ODataLinkType {
* Gets
* <code>LinkType</code> instance from the given rel and type.
*
* @param version OData protocol version.
* @param rel rel.
* @param type type.
* @return <code>ODataLinkType</code> object.

View File

@ -81,7 +81,6 @@ public enum EdmPrimitiveTypeKind {
/**
* Gets <tt>EdmPrimitiveTypeKind</tt> from a full-qualified type name, for the given OData protocol version.
*
* @param version OData protocol version.
* @param fqn full-qualified type name.
* @return <tt>EdmPrimitiveTypeKind</tt> object.
*/
@ -93,7 +92,6 @@ public enum EdmPrimitiveTypeKind {
* Gets <tt>EdmPrimitiveTypeKind</tt> from a full type expression (as <tt>Edm.Int32</tt>), for the given OData
* protocol version.
*
* @param version OData protocol version.
* @param fqn string value type.
* @return <tt>EdmPrimitiveTypeKind</tt> object.
*/

View File

@ -131,7 +131,7 @@ public class Schema extends AbstractEdmItem implements Annotatable{
/**
* All actions with the given name
* @param name
* @return
* @return a list of actions
*/
public List<Action> getActions(final String name) {
return getAllByName(name, getActions());
@ -149,7 +149,7 @@ public class Schema extends AbstractEdmItem implements Annotatable{
/**
* All functions with the given name
* @param name
* @return
* @return a list of functions
*/
public List<Function> getFunctions(final String name) {
return getAllByName(name, getFunctions());

View File

@ -57,7 +57,6 @@ public enum ODataFormat {
/**
* Gets format as {@link ContentType}.
* @param version OData service version.
* @return format as ContentType.
*/
public ContentType getContentType() {

View File

@ -53,7 +53,7 @@ public interface FixedFormatSerializer {
* Serializes a batch response
* @param batchResponses
* @param boundary
* @return
* @return response as an input stream
* @throws BatchSerializerException
*/
InputStream batchResponse(List<ODataResponsePart> batchResponses, String boundary) throws BatchSerializerException;

View File

@ -183,7 +183,7 @@ public class ODataJsonDeserializer implements ODataDeserializer {
public List<Parameter> actionParameters(InputStream stream, final EdmAction edmAction) throws DeserializerException {
try {
ObjectNode tree = parseJsonTree(stream);
ArrayList<Parameter> parameters = new ArrayList<Parameter>();
List<Parameter> parameters = new ArrayList<Parameter>();
consumeParameters(edmAction, tree, parameters);
assertJsonNodeIsEmpty(tree);
return parameters;
@ -208,33 +208,42 @@ public class ODataJsonDeserializer implements ODataDeserializer {
return tree;
}
private void consumeParameters(final EdmAction edmAction, ObjectNode node, ArrayList<Parameter> parameters)
private void consumeParameters(final EdmAction edmAction, ObjectNode node, List<Parameter> parameters)
throws DeserializerException {
for (final String name : edmAction.getParameterNames()) {
List<String> parameterNames = edmAction.getParameterNames();
if (edmAction.isBound()) {
// The binding parameter must not occur in the payload.
parameterNames = parameterNames.subList(1, parameterNames.size());
}
for (final String name : parameterNames) {
final EdmParameter edmParameter = edmAction.getParameter(name);
ParameterImpl parameter = new ParameterImpl();
parameter.setName(name);
JsonNode jsonNode = node.get(name);
if (jsonNode == null || jsonNode.isNull()) {
if (!edmParameter.isNullable()) {
throw new DeserializerException("Non-nullable parameter not present or null",
DeserializerException.MessageKeys.INVALID_NULL_PARAMETER, name);
}
}
switch (edmParameter.getType().getKind()) {
case PRIMITIVE:
case DEFINITION:
case ENUM:
Property consumePropertyNode =
consumePropertyNode(edmParameter.getName(), edmParameter.getType(), edmParameter.isCollection(),
edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter
.getScale(),
true, edmParameter.getMapping(),
jsonNode);
parameter.setValue(consumePropertyNode.getValueType(), consumePropertyNode.getValue());
parameters.add(parameter);
node.remove(name);
if (jsonNode == null || jsonNode.isNull()) {
if (!edmParameter.isNullable()) {
throw new DeserializerException("Non-nullable parameter not present or null",
DeserializerException.MessageKeys.INVALID_NULL_PARAMETER, name);
}
if (edmParameter.isCollection()) {
throw new DeserializerException("Collection must not be null for parameter: " + name,
DeserializerException.MessageKeys.INVALID_NULL_PARAMETER, name);
}
parameter.setValue(ValueType.PRIMITIVE, null);
} else {
Property consumePropertyNode =
consumePropertyNode(edmParameter.getName(), edmParameter.getType(), edmParameter.isCollection(),
edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter
.getScale(), true, edmParameter.getMapping(), jsonNode);
parameter.setValue(consumePropertyNode.getValueType(), consumePropertyNode.getValue());
parameters.add(parameter);
node.remove(name);
}
break;
case COMPLEX:
case ENTITY:

View File

@ -50,7 +50,7 @@ public class ActionProvider {
new FullQualifiedName(SchemaProvider.NAMESPACE, "BAETTwoKeyNavRTETTwoKeyNav");
public static final FullQualifiedName nameBAETAllPrimRT =
new FullQualifiedName(SchemaProvider.NAMESPACE, "BAESAllPrimRT");
new FullQualifiedName(SchemaProvider.NAMESPACE, "BAETAllPrimRT");
// Unbound Actions
public static final FullQualifiedName nameUARTString = new FullQualifiedName(SchemaProvider.NAMESPACE,
@ -77,74 +77,67 @@ public class ActionProvider {
public List<Action> getActions(final FullQualifiedName actionName) throws ODataException {
if (actionName.equals(nameUARTString)) {
return Arrays.asList(
new Action().setName(nameUARTString.getName())
.setReturnType(new ReturnType().setType(PropertyProvider.nameString))
);
return Collections.singletonList(
new Action().setName(nameUARTString.getName())
.setReturnType(new ReturnType().setType(PropertyProvider.nameString)));
} else if (actionName.equals(nameUARTCollStringTwoParam)) {
return Arrays.asList(
new Action().setName(nameUARTCollStringTwoParam.getName())
.setParameters(Arrays.asList(
new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16),
new Parameter().setName("ParameterDuration").setType(PropertyProvider.nameDuration)))
.setReturnType(new ReturnType().setType(PropertyProvider.nameString).setCollection(true))
);
return Collections.singletonList(
new Action().setName(nameUARTCollStringTwoParam.getName())
.setParameters(Arrays.asList(
new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16),
new Parameter().setName("ParameterDuration").setType(PropertyProvider.nameDuration)))
.setReturnType(new ReturnType().setType(PropertyProvider.nameString).setCollection(true)));
} else if (actionName.equals(nameUARTCTTwoPrimParam)) {
return Arrays.asList(
new Action().setName(nameUARTCTTwoPrimParam.getName())
.setParameters(Arrays.asList(
new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)
.setNullable(false)))
.setReturnType(
new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))
);
return Collections.singletonList(
new Action().setName(nameUARTCTTwoPrimParam.getName())
.setParameters(Collections.singletonList(
new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)
.setNullable(false)))
.setReturnType(
new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false)));
} else if (actionName.equals(nameUARTCollCTTwoPrimParam)) {
return Arrays.asList(
new Action().setName(nameUARTCollCTTwoPrimParam.getName())
.setParameters(Arrays.asList(
new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
.setReturnType(
new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true))
);
return Collections.singletonList(
new Action().setName(nameUARTCollCTTwoPrimParam.getName())
.setParameters(Collections.singletonList(
new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
.setReturnType(
new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true)));
} else if (actionName.equals(nameUARTETTwoKeyTwoPrimParam)) {
return Arrays.asList(
new Action().setName(nameUARTETTwoKeyTwoPrimParam.getName())
.setParameters(Arrays.asList(
new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETTwoKeyTwoPrim))
);
return Collections.singletonList(
new Action().setName(nameUARTETTwoKeyTwoPrimParam.getName())
.setParameters(Collections.singletonList(
new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETTwoKeyTwoPrim)));
} else if (actionName.equals(nameUARTCollETKeyNavParam)) {
return Arrays.asList(
new Action().setName(nameUARTCollETKeyNavParam.getName())
.setParameters(Arrays.asList(
new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true))
);
return Collections.singletonList(
new Action().setName(nameUARTCollETKeyNavParam.getName())
.setParameters(Collections.singletonList(
new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16)))
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true)));
} else if (actionName.equals(nameUARTETAllPrimParam)) {
return Arrays.asList(
new Action().setName(nameUARTETAllPrimParam.getName())
.setParameters(Arrays.asList(
new Parameter().setName("ParameterDate").setType(PropertyProvider.nameDate)))
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETAllPrim))
);
return Collections.singletonList(
new Action().setName(nameUARTETAllPrimParam.getName())
.setParameters(Collections.singletonList(
new Parameter().setName("ParameterDate").setType(PropertyProvider.nameDate)))
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETAllPrim)));
} else if (actionName.equals(nameUARTCollETAllPrimParam)) {
return Arrays.asList(
new Action().setName(nameUARTCollETAllPrimParam.getName())
.setParameters(Arrays.asList(
new Parameter().setName("ParameterTimeOfDay")
.setType(PropertyProvider.nameTimeOfDay)))
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETAllPrim).setCollection(true))
);
return Collections.singletonList(
new Action().setName(nameUARTCollETAllPrimParam.getName())
.setParameters(Collections.singletonList(
new Parameter().setName("ParameterTimeOfDay")
.setType(PropertyProvider.nameTimeOfDay)))
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETAllPrim).setCollection(true)));
} else if (actionName.equals(nameUART)) {
return Collections.singletonList(new Action().setName(nameUART.getName()));
@ -186,26 +179,22 @@ public class ActionProvider {
} else if (actionName.equals(nameBAESAllPrimRTETAllPrim)) {
return Arrays.asList(
new Action().setName("BAESAllPrimRTETAllPrim")
.setParameters(
Arrays.asList(
new Parameter().setName("ParameterESAllPrim").setType(EntityTypeProvider.nameETAllPrim)
.setCollection(true).setNullable(false)))
.setParameters(Arrays.asList(
new Parameter().setName("ParameterESAllPrim").setType(EntityTypeProvider.nameETAllPrim)
.setCollection(true).setNullable(false)))
.setBound(true)
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETAllPrim))
);
new ReturnType().setType(EntityTypeProvider.nameETAllPrim)));
} else if (actionName.equals(nameBAESTwoKeyNavRTESTwoKeyNav)) {
return Arrays.asList(
new Action().setName("BAESTwoKeyNavRTESTwoKeyNav")
.setParameters(
Arrays.asList(
new Parameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETTwoKeyNav)
.setCollection(true).setNullable(false)))
.setParameters(Arrays.asList(
new Parameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETTwoKeyNav)
.setCollection(true).setNullable(false)))
.setBound(true)
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true))
);
new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)));
} else if(actionName.equals(nameBAESTwoKeyNavRTESKeyNav)) {
return Arrays.asList(
@ -214,12 +203,12 @@ public class ActionProvider {
.setEntitySetPath("BindingParam/NavPropertyETKeyNavMany")
.setParameters(Arrays.asList(
new Parameter().setName("ParameterETTwoKeyNav")
.setType(EntityTypeProvider.nameETTwoKeyNav)
.setCollection(true)
.setNullable(false)
))
.setReturnType(new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true))
);
.setType(EntityTypeProvider.nameETTwoKeyNav)
.setCollection(true)
.setNullable(false)))
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true)));
} else if (actionName.equals(nameBAETBaseTwoKeyNavRTETBaseTwoKeyNav)) {
return Arrays.asList(
new Action().setName("BAETBaseTwoKeyNavRTETBaseTwoKeyNav")
@ -228,20 +217,19 @@ public class ActionProvider {
.setNullable(false)))
.setBound(true)
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav))
);
new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav)));
} else if (actionName.equals(nameBAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav)) {
return Arrays.asList(
new Action().setName("BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav")
.setParameters(
Arrays.asList(
new Parameter().setName("ParameterETTwoBaseTwoKeyNav").setType(
EntityTypeProvider.nameETTwoBaseTwoKeyNav).setNullable(false)))
.setParameters(Arrays.asList(
new Parameter().setName("ParameterETTwoBaseTwoKeyNav")
.setType(EntityTypeProvider.nameETTwoBaseTwoKeyNav)
.setNullable(false)))
.setBound(true)
.setReturnType(
new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav))
);
new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav)));
} else if(actionName.equals(nameBAETAllPrimRT)) {
return Arrays.asList(
new Action().setName("BAETAllPrimRT")
@ -249,17 +237,14 @@ public class ActionProvider {
.setParameters(Arrays.asList(
new Parameter().setName("ParameterETAllPrim")
.setNullable(false)
.setType(EntityTypeProvider.nameETAllPrim)
)),
.setType(EntityTypeProvider.nameETAllPrim))),
new Action().setName("BAETAllPrimRT")
.setBound(true)
.setParameters(Arrays.asList(
new Parameter().setName("ParameterETAllPrim")
.setNullable(false)
.setCollection(true)
.setType(EntityTypeProvider.nameETAllPrim)
))
);
.setType(EntityTypeProvider.nameETAllPrim))));
}
return null;

View File

@ -57,6 +57,29 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
assertEquals(BigDecimal.valueOf(3669753), parameter.getValue());
}
@Test
public void boundEmpty() throws Exception {
final String input = "{}";
final List<Parameter> parameters = deserialize(input, "BAETAllPrimRT", "ETAllPrim");
assertNotNull(parameters);
assertTrue(parameters.isEmpty());
}
@Test(expected = DeserializerException.class)
public void bindingParameter() throws Exception {
deserialize("{\"ParameterETAllPrim\":{\"PropertyInt16\":42}}", "BAETAllPrimRT", "ETAllPrim");
}
@Test(expected = DeserializerException.class)
public void wrongName() throws Exception {
deserialize("{\"ParameterWrong\":null}", "UARTParam");
}
@Test(expected = DeserializerException.class)
public void nullNotNullable() throws Exception {
deserialize("{\"ParameterInt16\":null}", "UARTCTTwoPrimParam");
}
@Test(expected = DeserializerException.class)
public void missingParameter() throws Exception {
deserialize("{}", "UARTCTTwoPrimParam");
@ -77,4 +100,12 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese
.actionParameters(new ByteArrayInputStream(input.getBytes()),
edm.getUnboundAction(new FullQualifiedName("Namespace1_Alias", actionName)));
}
private List<Parameter> deserialize(final String input, final String actionName, final String typeName)
throws DeserializerException {
return OData.newInstance().createDeserializer(ODataFormat.JSON)
.actionParameters(new ByteArrayInputStream(input.getBytes()),
edm.getBoundAction(new FullQualifiedName("Namespace1_Alias", actionName),
new FullQualifiedName("Namespace1_Alias", typeName), false));
}
}

View File

@ -286,7 +286,7 @@ public class FilterValidator implements TestValidator {
* Validates the serialized filterTree against a given filterString
* The given expected filterString is compressed before to allow better readable code in the unit tests
* @param toBeCompr
* @return
* @return {@link FilterValidator}
*/
public FilterValidator isCompr(final String toBeCompr) {
return is(compress(toBeCompr));

View File

@ -57,7 +57,7 @@ public class ParserValidator {
* Used in fast LL Parsing:
* Don't stop the parsing process when the slower full context parsing (with prediction mode SLL) is
* required
* @return
* @return {@link ParserValidator}
*/
public ParserValidator aFC() {
allowFullContext = true;
@ -68,7 +68,7 @@ public class ParserValidator {
* Used in fast LL Parsing:
* Allows ContextSensitifity Errors which occur often when using the slower full context parsing
* and indicate that there is a context sensitivity ( which may not be an error).
* @return
* @return {@link ParserValidator}
*/
public ParserValidator aCS() {
allowContextSensitifity = true;
@ -78,7 +78,7 @@ public class ParserValidator {
/**
* Used in fast LL Parsing:
* Allows ambiguities
* @return
* @return {@link ParserValidator}
*/
public ParserValidator aAM() {
allowAmbiguity = true;