[OLINGO-1143] Support of Expand of a navigation property of a complex type

This commit is contained in:
ramya vasanth 2018-04-11 11:15:38 +05:30
parent fd8bfa33d4
commit aaff527dcd
13 changed files with 997 additions and 106 deletions

View File

@ -0,0 +1,348 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* 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
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.fit.tecsvc.client;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.domain.ClientCollectionValue;
import org.apache.olingo.client.api.domain.ClientComplexValue;
import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientLink;
import org.apache.olingo.client.api.domain.ClientProperty;
import org.apache.olingo.client.api.domain.ClientValue;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
import org.junit.Test;
public class ExpandWithComplexPropertyITCase extends AbstractParamTecSvcITCase {
@Test
public void readExpandHavingComplexProperty1() {
ODataEntityRequest<ClientEntity> request = getClient().getRetrieveRequestFactory()
.getEntityRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESCompMixPrimCollComp").appendKeySegment(1)
.expand("PropertyMixedPrimCollComp/PropertyComp/NavPropertyETTwoKeyNavOne($expand=NavPropertySINav),"
+ "PropertyMixedPrimCollComp/PropertyComp/NavPropertyETMediaOne")
.build());
assertNotNull(request);
setCookieHeader(request);
final ODataRetrieveResponse<ClientEntity> response = request.execute();
saveCookieHeader(response);
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ClientEntity entity = response.getBody();
assertNotNull(entity);
assertNotNull(entity.getProperties());
assertEquals(2, entity.getProperties().size());
assertNotNull(entity.getProperty("PropertyMixedPrimCollComp"));
ClientProperty property = entity.getProperty("PropertyInt16");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertShortOrInt(Integer.valueOf(1), property.getPrimitiveValue().toValue());
property = entity.getProperty("PropertyMixedPrimCollComp");
assertNotNull(property);
ClientComplexValue complexValue = property.getComplexValue();
assertNotNull(complexValue);
property = complexValue.get("PropertyComp");
assertNotNull(property);
complexValue = property.getComplexValue();
assertNotNull(complexValue);
if (isJson()) {
property = complexValue.get("NavPropertyETTwoKeyNavOne");
assertNotNull(property);
assertNotNull(complexValue.get("NavPropertyETMediaOne"));
complexValue = property.getComplexValue();
assertNotNull(complexValue);
assertNotNull(complexValue.get("NavPropertySINav"));
} else {
ClientLink etkeyNavOneLink = complexValue.getNavigationLink("NavPropertyETTwoKeyNavOne");
assertNotNull(etkeyNavOneLink);
ClientEntity navEntity = etkeyNavOneLink.asInlineEntity().getEntity();
assertNotNull(navEntity.getNavigationLink("NavPropertySINav"));
assertNotNull(navEntity.getNavigationLink("NavPropertySINav").asInlineEntity().getEntity());
assertNotNull(complexValue.getNavigationLink("NavPropertyETMediaOne"));
}
}
@Test
public void readExpandHavingComplexProperty2() {
ODataEntityRequest<ClientEntity> request = getClient().getRetrieveRequestFactory()
.getEntityRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESCompMixPrimCollComp").appendKeySegment(1)
.expand("PropertyMixedPrimCollComp/NavPropertyETTwoKeyNavOne,"
+ "PropertyMixedPrimCollComp/PropertyComp/NavPropertyETMediaOne")
.build());
assertNotNull(request);
setCookieHeader(request);
if (isJson()) {
request.setAccept("application/json;odata.metadata=full");
}
final ODataRetrieveResponse<ClientEntity> response = request.execute();
saveCookieHeader(response);
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ClientEntity entity = response.getBody();
assertNotNull(entity);
assertNotNull(entity.getProperties());
assertEquals(2, entity.getProperties().size());
assertNotNull(entity.getProperty("PropertyMixedPrimCollComp"));
ClientProperty property = entity.getProperty("PropertyInt16");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertShortOrInt(Integer.valueOf(1), property.getPrimitiveValue().toValue());
property = entity.getProperty("PropertyMixedPrimCollComp");
assertNotNull(property);
ClientComplexValue complexValue = property.getComplexValue();
assertNotNull(complexValue);
ClientLink etkeyNavLink = complexValue.getNavigationLink("NavPropertyETTwoKeyNavOne");
assertNotNull(etkeyNavLink);
assertNotNull(etkeyNavLink.asInlineEntity().getEntity());
property = complexValue.get("PropertyComp");
assertNotNull(property);
complexValue = property.getComplexValue();
assertNotNull(complexValue);
ClientLink etMediaOneNav = complexValue.getNavigationLink("NavPropertyETMediaOne");
assertNotNull(etMediaOneNav);
assertNotNull(etMediaOneNav.asInlineEntity().getEntity());
}
@Test
public void readExpandHavingComplexProperty3() {
ODataEntityRequest<ClientEntity> request = getClient().getRetrieveRequestFactory()
.getEntityRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESCompMixPrimCollComp").appendKeySegment(1)
.expand("PropertyMixedPrimCollComp/NavPropertyETTwoKeyNavOne,"
+ "PropertyMixedPrimCollComp/PropertyComp/NavPropertyETMediaOne,"
+ "PropertyMixedPrimCollComp/PropertyComp/NavPropertyETTwoKeyNavOne")
.build());
assertNotNull(request);
setCookieHeader(request);
final ODataRetrieveResponse<ClientEntity> response = request.execute();
saveCookieHeader(response);
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ClientEntity entity = response.getBody();
assertNotNull(entity);
assertNotNull(entity.getProperties());
assertEquals(2, entity.getProperties().size());
assertNotNull(entity.getProperty("PropertyMixedPrimCollComp"));
ClientProperty property = entity.getProperty("PropertyInt16");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertShortOrInt(Integer.valueOf(1), property.getPrimitiveValue().toValue());
property = entity.getProperty("PropertyMixedPrimCollComp");
assertNotNull(property);
ClientComplexValue complexValue = property.getComplexValue();
assertNotNull(complexValue);
if (isJson()) {
assertNotNull(complexValue.get("NavPropertyETTwoKeyNavOne"));
} else {
assertNotNull(complexValue.getNavigationLink("NavPropertyETTwoKeyNavOne"));
}
property = complexValue.get("PropertyComp");
assertNotNull(property);
complexValue = property.getComplexValue();
assertNotNull(complexValue);
if (isJson()) {
assertNotNull(complexValue.get("NavPropertyETMediaOne"));
assertNotNull(complexValue.get("NavPropertyETTwoKeyNavOne"));
} else {
assertNotNull(complexValue.getNavigationLink("NavPropertyETMediaOne"));
assertNotNull(complexValue.getNavigationLink("NavPropertyETMediaOne").asInlineEntity().getEntity());
assertNotNull(complexValue.getNavigationLink("NavPropertyETTwoKeyNavOne"));
assertNotNull(complexValue.getNavigationLink("NavPropertyETTwoKeyNavOne").asInlineEntity().getEntity());
}
}
@Test
public void readExpandHavingCollComplexProperty1() {
ODataEntityRequest<ClientEntity> request = getClient().getRetrieveRequestFactory()
.getEntityRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESCompMixPrimCollComp").appendKeySegment(1)
.expand("PropertyMixedPrimCollComp/CollPropertyComp/NavPropertyETTwoKeyNavOne")
.build());
assertNotNull(request);
setCookieHeader(request);
final ODataRetrieveResponse<ClientEntity> response = request.execute();
saveCookieHeader(response);
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ClientEntity entity = response.getBody();
assertNotNull(entity);
assertNotNull(entity.getProperties());
assertEquals(2, entity.getProperties().size());
assertNotNull(entity.getProperty("PropertyMixedPrimCollComp"));
ClientProperty property = entity.getProperty("PropertyInt16");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertShortOrInt(Integer.valueOf(1), property.getPrimitiveValue().toValue());
property = entity.getProperty("PropertyMixedPrimCollComp");
assertNotNull(property);
ClientComplexValue complexValue = property.getComplexValue();
assertNotNull(complexValue);
property = complexValue.get("CollPropertyComp");
assertNotNull(property);
ClientCollectionValue<ClientValue> complexValues = property.getCollectionValue();
assertNotNull(complexValues);
for (ClientValue value : complexValues) {
if (isJson()) {
ClientComplexValue innerComplexValue = value.asComplex();
assertNotNull(innerComplexValue.get("NavPropertyETTwoKeyNavOne"));
property = innerComplexValue.get("NavPropertyETTwoKeyNavOne");
assertEquals(8, property.getValue().asComplex().size());
} else {
ClientComplexValue innerComplexValue = value.asComplex();
ClientLink link = innerComplexValue.getNavigationLink("NavPropertyETTwoKeyNavOne");
assertNotNull(link);
assertNotNull(link.asInlineEntity());
assertEquals(8, link.asInlineEntity().getEntity().getProperties().size());
}
}
}
@Test
public void readExpandHavingCollComplexProperty2() {
ODataEntityRequest<ClientEntity> request = getClient().getRetrieveRequestFactory()
.getEntityRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESMixPrimCollComp").appendKeySegment(32767)
.expand("CollPropertyComp/NavPropertyETTwoKeyNavOne,PropertyComp/NavPropertyETTwoKeyNavOne")
.build());
assertNotNull(request);
setCookieHeader(request);
if (isJson()) {
request.setAccept("application/json;odata.metadata=full");
}
final ODataRetrieveResponse<ClientEntity> response = request.execute();
saveCookieHeader(response);
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ClientEntity entity = response.getBody();
assertNotNull(entity);
assertNotNull(entity.getProperties());
assertEquals(4, entity.getProperties().size());
assertNotNull(entity.getProperty("CollPropertyComp"));
ClientProperty property = entity.getProperty("CollPropertyComp");
assertNotNull(property);
ClientCollectionValue<ClientValue> complexValues = property.getCollectionValue();
assertNotNull(complexValues);
assertEquals(3, complexValues.size());
for (ClientValue value : complexValues) {
ClientComplexValue complexValue = value.asComplex();
ClientLink link = complexValue.getNavigationLink("NavPropertyETTwoKeyNavOne");
assertNotNull(link);
assertNotNull(link.asInlineEntity());
assertEquals(8, link.asInlineEntity().getEntity().getProperties().size());
}
property = entity.getProperty("PropertyComp");
assertNotNull(property);
ClientComplexValue complexValue = property.getComplexValue();
assertNotNull(complexValue);
ClientLink link = complexValue.getNavigationLink("NavPropertyETTwoKeyNavOne");
assertNotNull(link);
assertNotNull(link.asInlineEntity());
assertEquals(8, link.asInlineEntity().getEntity().getProperties().size());
}
@Test
public void readExpandHavingCollComplexPropertyWith$ref$count() {
ODataEntityRequest<ClientEntity> request = getClient().getRetrieveRequestFactory()
.getEntityRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESCompMixPrimCollComp").appendKeySegment(1)
.expand("PropertyMixedPrimCollComp/PropertyComp/NavPropertyETTwoKeyNavOne/$ref,"
+ "PropertyMixedPrimCollComp/PropertyComp/NavPropertyETMediaOne/$ref,"
+ "PropertyMixedPrimCollComp/NavPropertyETTwoKeyNavMany/$count")
.build());
assertNotNull(request);
setCookieHeader(request);
final ODataRetrieveResponse<ClientEntity> response = request.execute();
saveCookieHeader(response);
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ClientEntity entity = response.getBody();
assertNotNull(entity);
assertNotNull(entity.getProperties());
assertEquals(2, entity.getProperties().size());
ClientProperty property = entity.getProperty("PropertyMixedPrimCollComp");
assertNotNull(property);
ClientComplexValue complexValue = property.getComplexValue();
assertNotNull(complexValue);
ClientLink link = null;
if (isJson()) {
property = complexValue.get("NavPropertyETTwoKeyNavMany@odata.count");
assertNotNull(property.getPrimitiveValue());
assertEquals(Integer.valueOf(2), property.getPrimitiveValue().toValue());
} else {
link = complexValue.getNavigationLink("NavPropertyETTwoKeyNavMany");
assertNotNull(link);
assertNotNull(link.getLink());
assertNotNull(link.asInlineEntitySet().getEntitySet());
assertEquals(Integer.valueOf(2), link.asInlineEntitySet().getEntitySet().getCount());
}
property = complexValue.get("PropertyComp");
assertNotNull(property);
ClientComplexValue innerComplexValue = property.getComplexValue();
assertNotNull(innerComplexValue);
if (isJson()) {
property = innerComplexValue.get("NavPropertyETTwoKeyNavOne");
assertNotNull(property);
assertEquals("odata.id", property.getComplexValue().getAnnotations().get(0).getTerm());
assertEquals(String.valueOf("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')"),
property.getComplexValue().getAnnotations().get(0).getPrimitiveValue().toValue());
property = innerComplexValue.get("NavPropertyETMediaOne");
assertNotNull(property);
assertEquals("odata.id", property.getComplexValue().getAnnotations().get(3).getTerm());
assertEquals(String.valueOf("ESMedia(2)"),
property.getComplexValue().getAnnotations().get(3).getPrimitiveValue().toValue());
} else {
link = innerComplexValue.getNavigationLink("NavPropertyETTwoKeyNavOne");
assertNotNull(link);
assertNotNull(link.getLink());
link = innerComplexValue.getNavigationLink("NavPropertyETMediaOne");
assertNotNull(link);
assertNotNull(link.getLink());
}
}
}

View File

@ -188,70 +188,65 @@ public class DerivedAndMixedTypeTestITCase extends AbstractBaseTestITCase {
ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE))); ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));
final String content = IOUtils.toString(connection.getInputStream()); final String content = IOUtils.toString(connection.getInputStream());
final String actualContent = "\"value\":" final String actualContent = "\"value\":[{\"@odata.type\":\"#olingo.odata.test1.ETMixPrimCollComp\","
+ "[{\"@odata.type\":\"#olingo.odata.test1.ETMixPrimCollComp\","
+ "\"@odata.id\":\"ESMixPrimCollComp(32767)\"," + "\"@odata.id\":\"ESMixPrimCollComp(32767)\","
+ "\"PropertyInt16@odata.type\":\"#Int16\"," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":32767,"
+ "\"PropertyInt16\":32767,"
+ "\"CollPropertyString@odata.type\":\"#Collection(String)\"," + "\"CollPropertyString@odata.type\":\"#Collection(String)\","
+ "\"CollPropertyString\":" + "\"CollPropertyString\":[\"Employee1@company.example\",\"Employee2@company.example\","
+ "[\"Employee1@company.example\",\"Employee2@company.example\","
+ "\"Employee3@company.example\"]," + "\"Employee3@company.example\"],"
+ "\"PropertyComp\":" + "\"PropertyComp\":{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":111," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":111,"
+ "\"PropertyString\":\"TEST A\"}," + "\"PropertyString\":\"TEST A\","
+ "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='1')\"},"
+ "\"CollPropertyComp@odata.type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\"," + "\"CollPropertyComp@odata.type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\","
+ "\"CollPropertyComp\":" + "\"CollPropertyComp\":[{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "[{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":123," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":123,"
+ "\"PropertyString\":\"TEST 1\"}," + "\"PropertyString\":\"TEST 1\","
+ "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"},"
+ "{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\"," + "{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\"," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":456,"
+ "\"PropertyInt16\":456," + "\"PropertyString\":\"TEST 2\","
+ "\"PropertyString\":\"TEST 2\"}," + "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"},"
+ "{\"@odata.type\":\"#olingo.odata.test1.CTBase\"," + "{\"@odata.type\":\"#olingo.odata.test1.CTBase\",\"PropertyInt16@odata.type\":\"#Int16\","
+ "\"PropertyInt16@odata.type\":\"#Int16\"," + "\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\","
+ "\"PropertyInt16\":789," + "\"AdditionalPropString\":\"ADD TEST\","
+ "\"PropertyString\":\"TEST 3\"," + "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"}],"
+ "\"AdditionalPropString\":\"ADD TEST\"}],"
+ "\"#olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\":" + "\"#olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\":"
+ "{\"title\":\"olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\"," + "{\"title\":\"olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\","
+ "\"target\":\"ESMixPrimCollComp(32767)/olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\"}}," + "\"target\":\"ESMixPrimCollComp(32767)/olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\"}},"
+ "{\"@odata.type\":\"#olingo.odata.test1.ETMixPrimCollComp\"," + "{\"@odata.type\":\"#olingo.odata.test1.ETMixPrimCollComp\","
+ "\"@odata.id\":\"ESMixPrimCollComp(7)\"," + "\"@odata.id\":\"ESMixPrimCollComp(7)\","
+ "\"PropertyInt16@odata.type\":\"#Int16\"," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":7,"
+ "\"PropertyInt16\":7,\"CollPropertyString@odata.type\":\"#Collection(String)\"," + "\"CollPropertyString@odata.type\":\"#Collection(String)\","
+ "\"CollPropertyString\":[\"Employee1@company.example\"," + "\"CollPropertyString\":[\"Employee1@company.example\",\"Employee2@company.example\","
+ "\"Employee2@company.example\","
+ "\"Employee3@company.example\"]," + "\"Employee3@company.example\"],"
+ "\"PropertyComp\":{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\"," + "\"PropertyComp\":{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":222,\"PropertyString\":\"TEST B\"}," + "\"PropertyInt16@odata.type\":\"#Int16\","
+ "\"PropertyInt16\":222,\"PropertyString\":\"TEST B\"},"
+ "\"CollPropertyComp@odata.type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\"," + "\"CollPropertyComp@odata.type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\","
+ "\"CollPropertyComp\":[{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\"," + "\"CollPropertyComp\":[{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"}," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":123,"
+ "{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\",\"PropertyInt16@odata.type\":\"#Int16\"," + "\"PropertyString\":\"TEST 1\"},{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},{\"@odata.type\":\"#olingo.odata.test1.CTBase\"," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"," + "{\"@odata.type\":\"#olingo.odata.test1.CTBase\",\"PropertyInt16@odata.type\":\"#Int16\","
+ "\"AdditionalPropString\":\"ADD TEST\"}]," + "\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\",\"AdditionalPropString\":\"ADD TEST\"}],"
+ "\"#olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\":" + "\"#olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\":"
+ "{\"title\":\"olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\"," + "{\"title\":\"olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\","
+ "\"target\":\"ESMixPrimCollComp(7)/olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\"}}," + "\"target\":\"ESMixPrimCollComp(7)/olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\"}},"
+ "{\"@odata.type\":\"#olingo.odata.test1.ETMixPrimCollComp\"," + "{\"@odata.type\":\"#olingo.odata.test1.ETMixPrimCollComp\",\"@odata.id\":\"ESMixPrimCollComp(0)\","
+ "\"@odata.id\":\"ESMixPrimCollComp(0)\",\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":0," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":0,"
+ "\"CollPropertyString@odata.type\":\"#Collection(String)\",\"CollPropertyString\":" + "\"CollPropertyString@odata.type\":\"#Collection(String)\","
+ "[\"Employee1@company.example\",\"Employee2@company.example\",\"Employee3@company.example\"]," + "\"CollPropertyString\":[\"Employee1@company.example\",\"Employee2@company.example\","
+ "\"PropertyComp\":{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\",\"PropertyInt16@odata.type\":\"#Int16\"," + "\"Employee3@company.example\"],"
+ "\"PropertyInt16\":333,\"PropertyString\":\"TEST C\"}," + "\"PropertyComp\":{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":333,\"PropertyString\":\"TEST C\"},"
+ "\"CollPropertyComp@odata.type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\"," + "\"CollPropertyComp@odata.type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\","
+ "\"CollPropertyComp\":" + "\"CollPropertyComp\":[{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "[{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\"," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":123,"
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"}," + "\"PropertyString\":\"TEST 1\"},{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"}," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
+ "{\"@odata.type\":\"#olingo.odata.test1.CTBase\"," + "{\"@odata.type\":\"#olingo.odata.test1.CTBase\",\"PropertyInt16@odata.type\":\"#Int16\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"," + "\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\",\"AdditionalPropString\":\"ADD TEST\"}],"
+ "\"AdditionalPropString\":\"ADD TEST\"}],"
+ "\"#olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\":" + "\"#olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\":"
+ "{\"title\":\"olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\"," + "{\"title\":\"olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\","
+ "\"target\":\"ESMixPrimCollComp(0)/olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\"}}]"; + "\"target\":\"ESMixPrimCollComp(0)/olingo.odata.test1.BAETMixPrimCollCompRTCTTwoPrim\"}}]";

View File

@ -450,7 +450,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
} }
} }
writeProperties(metadata, resolvedType, entity.getProperties(), select, json); writeProperties(metadata, resolvedType, entity.getProperties(), select, json, entity, expand);
writeExpandedStreamProperties(metadata, resolvedType, entity, expand, toDepth, ancestors, name, json); writeExpandedStreamProperties(metadata, resolvedType, entity, expand, toDepth, ancestors, name, json);
writeNavigationProperties(metadata, resolvedType, entity, expand, toDepth, ancestors, name, json); writeNavigationProperties(metadata, resolvedType, entity, expand, toDepth, ancestors, name, json);
writeOperations(entity.getOperations(), json); writeOperations(entity.getOperations(), json);
@ -525,19 +525,20 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type,
final List<Property> properties, final List<Property> properties,
final SelectOption select, final JsonGenerator json) final SelectOption select, final JsonGenerator json, Linked linked, ExpandOption expand)
throws IOException, SerializerException { throws IOException, SerializerException {
final boolean all = ExpandSelectHelper.isAll(select); final boolean all = ExpandSelectHelper.isAll(select);
final Set<String> selected = all ? new HashSet<String>() : final Set<String> selected = all ? new HashSet<String>() :
ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems()); ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
addKeyPropertiesToSelected(selected, type); addKeyPropertiesToSelected(selected, type);
Set<List<String>> expandedPaths = ExpandSelectHelper.getExpandedItemsPath(expand);
for (final String propertyName : type.getPropertyNames()) { for (final String propertyName : type.getPropertyNames()) {
if (all || selected.contains(propertyName)) { if (all || selected.contains(propertyName)) {
final EdmProperty edmProperty = type.getStructuralProperty(propertyName); final EdmProperty edmProperty = type.getStructuralProperty(propertyName);
final Property property = findProperty(propertyName, properties); final Property property = findProperty(propertyName, properties);
final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null :
ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName); ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName);
writeProperty(metadata, edmProperty, property, selectedPaths, json); writeProperty(metadata, edmProperty, property, selectedPaths, json, expandedPaths, linked, expand);
} }
} }
} }
@ -572,7 +573,8 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
if ((toDepth != null && toDepth > 1) || (toDepth == null && ExpandSelectHelper.hasExpand(expand))) { if ((toDepth != null && toDepth > 1) || (toDepth == null && ExpandSelectHelper.hasExpand(expand))) {
final ExpandItem expandAll = ExpandSelectHelper.getExpandAll(expand); final ExpandItem expandAll = ExpandSelectHelper.getExpandAll(expand);
for (final String propertyName : type.getNavigationPropertyNames()) { for (final String propertyName : type.getNavigationPropertyNames()) {
final ExpandItem innerOptions = ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName); final ExpandItem innerOptions = ExpandSelectHelper.getExpandItemBasedOnType(expand.getExpandItems(),
propertyName, type, name);
if (innerOptions != null || expandAll != null || toDepth != null) { if (innerOptions != null || expandAll != null || toDepth != null) {
Integer levels = null; Integer levels = null;
final EdmNavigationProperty property = type.getNavigationProperty(propertyName); final EdmNavigationProperty property = type.getNavigationProperty(propertyName);
@ -698,7 +700,8 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
protected void writeProperty(final ServiceMetadata metadata, protected void writeProperty(final ServiceMetadata metadata,
final EdmProperty edmProperty, final Property property, final EdmProperty edmProperty, final Property property,
final Set<List<String>> selectedPaths, final JsonGenerator json) final Set<List<String>> selectedPaths, final JsonGenerator json,
Set<List<String>> expandedPaths, Linked linked, ExpandOption expand)
throws IOException, SerializerException { throws IOException, SerializerException {
boolean isStreamProperty = isStreamProperty(edmProperty); boolean isStreamProperty = isStreamProperty(edmProperty);
writePropertyType(edmProperty, json); writePropertyType(edmProperty, json);
@ -720,7 +723,8 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
} }
} }
} else { } else {
writePropertyValue(metadata, edmProperty, property, selectedPaths, json); writePropertyValue(metadata, edmProperty, property, selectedPaths, json,
expandedPaths, linked, expand);
} }
} }
@ -762,7 +766,8 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
} }
private void writePropertyValue(final ServiceMetadata metadata, final EdmProperty edmProperty, private void writePropertyValue(final ServiceMetadata metadata, final EdmProperty edmProperty,
final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json) final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json,
Set<List<String>> expandedPaths, Linked linked, ExpandOption expand)
throws IOException, SerializerException { throws IOException, SerializerException {
final EdmType type = edmProperty.getType(); final EdmType type = edmProperty.getType();
try { try {
@ -779,9 +784,11 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
} }
} else if (property.isComplex()) { } else if (property.isComplex()) {
if (edmProperty.isCollection()) { if (edmProperty.isCollection()) {
writeComplexCollection(metadata, (EdmComplexType) type, property, selectedPaths, json); writeComplexCollection(metadata, (EdmComplexType) type, property, selectedPaths,
json, expandedPaths, linked, expand);
} else { } else {
writeComplex(metadata, (EdmComplexType) type, property, selectedPaths, json); writeComplex(metadata, (EdmComplexType) type, property, selectedPaths, json,
expandedPaths, linked, expand);
} }
} else { } else {
throw new SerializerException("Property type not yet supported!", throw new SerializerException("Property type not yet supported!",
@ -795,7 +802,8 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
} }
private void writeComplex(final ServiceMetadata metadata, final EdmComplexType type, private void writeComplex(final ServiceMetadata metadata, final EdmComplexType type,
final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json) final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json,
Set<List<String>> expandedPaths, Linked linked, ExpandOption expand)
throws IOException, SerializerException{ throws IOException, SerializerException{
json.writeStartObject(); json.writeStartObject();
String derivedName = property.getType(); String derivedName = property.getType();
@ -816,9 +824,26 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
if (!isODataMetadataNone && !resolvedType.equals(type) || isODataMetadataFull) { if (!isODataMetadataNone && !resolvedType.equals(type) || isODataMetadataFull) {
json.writeStringField(constants.getType(), "#" + json.writeStringField(constants.getType(), "#" +
resolvedType.getFullQualifiedName().getFullQualifiedNameAsString()); resolvedType.getFullQualifiedName().getFullQualifiedNameAsString());
} }
if (null != linked) {
if (linked instanceof Entity) {
linked = ((Entity)linked).getProperty(property.getName()).asComplex();
} else if (linked instanceof ComplexValue) {
List<Property> complexProperties = ((ComplexValue)linked).getValue();
for (Property prop : complexProperties) {
if (prop.getName().equals(property.getName())) {
linked = prop.asComplex();
break;
}
}
}
expandedPaths = expandedPaths == null || expandedPaths.isEmpty() ? null :
ExpandSelectHelper.getReducedExpandItemsPaths(expandedPaths, property.getName());
}
writeComplexValue(metadata, resolvedType, property.asComplex().getValue(), selectedPaths, writeComplexValue(metadata, resolvedType, property.asComplex().getValue(), selectedPaths,
json); json, expandedPaths, linked, expand, property.getName());
json.writeEndObject(); json.writeEndObject();
} }
@ -851,13 +876,17 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
private void writeComplexCollection(final ServiceMetadata metadata, final EdmComplexType type, private void writeComplexCollection(final ServiceMetadata metadata, final EdmComplexType type,
final Property property, final Property property,
final Set<List<String>> selectedPaths, final JsonGenerator json) final Set<List<String>> selectedPaths, final JsonGenerator json,
Set<List<String>> expandedPaths, Linked linked, ExpandOption expand)
throws IOException, SerializerException { throws IOException, SerializerException {
json.writeStartArray(); json.writeStartArray();
EdmComplexType derivedType = type; EdmComplexType derivedType = type;
Set<List<String>> expandedPaths1 = expandedPaths != null && !expandedPaths.isEmpty() ?
expandedPaths : ExpandSelectHelper.getExpandedItemsPath(expand);
for (Object value : property.asCollection()) { for (Object value : property.asCollection()) {
expandedPaths = expandedPaths1;
derivedType = ((ComplexValue) value).getTypeName()!=null ? metadata.getEdm().getComplexType derivedType = ((ComplexValue) value).getTypeName()!=null ? metadata.getEdm().getComplexType
(new FullQualifiedName(((ComplexValue) value).getTypeName())): type; (new FullQualifiedName(((ComplexValue) value).getTypeName())): type;
switch (property.getValueType()) { switch (property.getValueType()) {
case COLLECTION_COMPLEX: case COLLECTION_COMPLEX:
json.writeStartObject(); json.writeStartObject();
@ -865,7 +894,10 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
json.writeStringField(constants.getType(), "#" + json.writeStringField(constants.getType(), "#" +
derivedType.getFullQualifiedName().getFullQualifiedNameAsString()); derivedType.getFullQualifiedName().getFullQualifiedNameAsString());
} }
writeComplexValue(metadata, derivedType, ((ComplexValue) value).getValue(), selectedPaths, json); expandedPaths = expandedPaths == null || expandedPaths.isEmpty() ? null :
ExpandSelectHelper.getReducedExpandItemsPaths(expandedPaths, property.getName());
writeComplexValue(metadata, derivedType, ((ComplexValue) value).getValue(),
selectedPaths, json, expandedPaths, (ComplexValue) value, expand, property.getName());
json.writeEndObject(); json.writeEndObject();
break; break;
default: default:
@ -1033,17 +1065,31 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
protected void writeComplexValue(final ServiceMetadata metadata, protected void writeComplexValue(final ServiceMetadata metadata,
final EdmComplexType type, final List<Property> properties, final EdmComplexType type, final List<Property> properties,
final Set<List<String>> selectedPaths, final JsonGenerator json) final Set<List<String>> selectedPaths, final JsonGenerator json,
Set<List<String>> expandedPaths, Linked linked, ExpandOption expand, String complexPropName)
throws IOException, SerializerException { throws IOException, SerializerException {
if (null != expandedPaths) {
for(List<String> paths : expandedPaths) {
if (!paths.isEmpty() && paths.size() == 1) {
expandedPaths = ExpandSelectHelper.getReducedExpandItemsPaths(expandedPaths, paths.get(0));
}
}
}
for (final String propertyName : type.getPropertyNames()) { for (final String propertyName : type.getPropertyNames()) {
final Property property = findProperty(propertyName, properties); final Property property = findProperty(propertyName, properties);
if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths, propertyName)) { if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths, propertyName)) {
writeProperty(metadata, (EdmProperty) type.getProperty(propertyName), property, writeProperty(metadata, (EdmProperty) type.getProperty(propertyName), property,
selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths, propertyName), selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths, propertyName),
json); json, expandedPaths, linked, expand);
} }
} }
try {
writeNavigationProperties(metadata, type, linked, expand, null, null, complexPropName, json);
} catch (DecoderException e) {
throw new SerializerException(IO_EXCEPTION_TEXT, e, SerializerException.MessageKeys.IO_EXCEPTION);
}
} }
private Property findProperty(final String propertyName, final List<Property> properties) { private Property findProperty(final String propertyName, final List<Property> properties) {
@ -1135,7 +1181,9 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
writeOperations(property.getOperations(), json); writeOperations(property.getOperations(), json);
final List<Property> values = final List<Property> values =
property.isNull() ? Collections.<Property> emptyList() : property.asComplex().getValue(); property.isNull() ? Collections.<Property> emptyList() : property.asComplex().getValue();
writeProperties(metadata, type, values, options == null ? null : options.getSelect(), json); writeProperties(metadata, type, values, options == null ? null : options == null ? null : options.getSelect(),
json,
property.asComplex(), options == null ? null : options.getExpand());
if (!property.isNull() && property.isComplex()) { if (!property.isNull() && property.isComplex()) {
writeNavigationProperties(metadata, type, property.asComplex(), writeNavigationProperties(metadata, type, property.asComplex(),
options == null ? null : options.getExpand(), null, null, name, json); options == null ? null : options.getExpand(), null, null, name, json);
@ -1221,7 +1269,12 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
selectedPaths = all || property.isPrimitive() ? null : ExpandSelectHelper selectedPaths = all || property.isPrimitive() ? null : ExpandSelectHelper
.getSelectedPaths(options.getSelect().getSelectItems()); .getSelectedPaths(options.getSelect().getSelectItems());
} }
writeComplexCollection(metadata, type, property, selectedPaths, json); Set<List<String>> expandPaths = null;
if (null != options && null != options.getExpand()) {
expandPaths = ExpandSelectHelper.getExpandedItemsPath(options.getExpand());
}
writeComplexCollection(metadata, type, property, selectedPaths, json, expandPaths, null,
options == null ? null : options.getExpand());
json.writeEndObject(); json.writeEndObject();
json.close(); json.close();

View File

@ -23,14 +23,17 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.olingo.commons.api.edm.EdmStructuredType;
import org.apache.olingo.server.api.serializer.SerializerException; import org.apache.olingo.server.api.serializer.SerializerException;
import org.apache.olingo.server.api.uri.UriResource; import org.apache.olingo.server.api.uri.UriResource;
import org.apache.olingo.server.api.uri.UriResourceAction; import org.apache.olingo.server.api.uri.UriResourceAction;
import org.apache.olingo.server.api.uri.UriResourceComplexProperty; import org.apache.olingo.server.api.uri.UriResourceComplexProperty;
import org.apache.olingo.server.api.uri.UriResourceCount;
import org.apache.olingo.server.api.uri.UriResourceEntitySet; import org.apache.olingo.server.api.uri.UriResourceEntitySet;
import org.apache.olingo.server.api.uri.UriResourceFunction; import org.apache.olingo.server.api.uri.UriResourceFunction;
import org.apache.olingo.server.api.uri.UriResourceNavigation; import org.apache.olingo.server.api.uri.UriResourceNavigation;
import org.apache.olingo.server.api.uri.UriResourceProperty; import org.apache.olingo.server.api.uri.UriResourceProperty;
import org.apache.olingo.server.api.uri.UriResourceRef;
import org.apache.olingo.server.api.uri.queryoption.ExpandItem; import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
import org.apache.olingo.server.api.uri.queryoption.ExpandOption; import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
import org.apache.olingo.server.api.uri.queryoption.SelectItem; import org.apache.olingo.server.api.uri.queryoption.SelectItem;
@ -222,7 +225,7 @@ public abstract class ExpandSelectHelper {
for (final ExpandItem item : expand.getExpandItems()) { for (final ExpandItem item : expand.getExpandItems()) {
if (item.isStar()) { if (item.isStar()) {
return item; return item;
} }
} }
return null; return null;
} }
@ -245,7 +248,8 @@ public abstract class ExpandSelectHelper {
if (item.isStar()) { if (item.isStar()) {
continue; continue;
} }
final UriResource resource = item.getResourcePath().getUriResourceParts().get(0); final List<UriResource> resourceParts = item.getResourcePath().getUriResourceParts();
final UriResource resource = resourceParts.get(0);
if ((resource instanceof UriResourceNavigation if ((resource instanceof UriResourceNavigation
&& propertyName.equals(((UriResourceNavigation) resource).getProperty().getName())) || && propertyName.equals(((UriResourceNavigation) resource).getProperty().getName())) ||
resource instanceof UriResourceProperty resource instanceof UriResourceProperty
@ -256,4 +260,126 @@ public abstract class ExpandSelectHelper {
return null; return null;
} }
public static Set<List<String>> getExpandedItemsPath(ExpandOption expand) {
Set<List<String>> expandPaths = new HashSet<List<String>>();
if (expand != null) {
List<ExpandItem> expandItems = expand.getExpandItems();
for (ExpandItem item : expandItems) {
if (item.isStar()) {
continue;
}
List<UriResource> resourceParts = item.getResourcePath().getUriResourceParts();
if (resourceParts.get(0) instanceof UriResourceComplexProperty) {
List<String> path = new ArrayList<String>();
for (UriResource resource : resourceParts) {
if (resource instanceof UriResourceNavigation) {
path.add(((UriResourceNavigation) resource).getProperty().getName());
} else if (resource instanceof UriResourceProperty) {
path.add(((UriResourceProperty) resource).getProperty().getName());
}
}
expandPaths.add(path);
}
}
}
return expandPaths;
}
public static Set<List<String>> getReducedExpandItemsPaths(final Set<List<String>> expandItemsPaths,
final String propertyName) {
Set<List<String>> reducedPaths = new HashSet<List<String>>();
for (final List<String> path : expandItemsPaths) {
if (propertyName.equals(path.get(0))) {
if (path.size() > 1) {
reducedPaths.add(path.subList(1, path.size()));
}
} else {
reducedPaths.add(path);
}
}
return reducedPaths.isEmpty() ? null : reducedPaths;
}
/**
* Fetches the expand Item depending upon the type
* @param expandItems
* @param propertyName
* @param type
* @param resourceName
* @return
*/
public static ExpandItem getExpandItemBasedOnType(final List<ExpandItem> expandItems,
final String propertyName, final EdmStructuredType type, String resourceName) {
ExpandItem expandItem = null;
for (final ExpandItem item : expandItems) {
boolean matched = false;
if (item.isStar()) {
continue;
}
final List<UriResource> resourceParts = item.getResourcePath().getUriResourceParts();
UriResource resource = null;
if (resourceParts.size() == 1) {
resource = resourceParts.get(0);
matched = true;
expandItem = getMatchedExpandItem(propertyName, item, matched, resource);
} else if (resourceParts.get(resourceParts.size() - 1) instanceof UriResourceRef ||
resourceParts.get(resourceParts.size() - 1) instanceof UriResourceCount) {
if (resourceParts.size() == 2) {
resource = resourceParts.get(0);
matched = true;
expandItem = getMatchedExpandItem(propertyName, item, matched, resource);
} else {
resource = resourceParts.get(resourceParts.size() - 3);
matched = resource.getSegmentValue().equalsIgnoreCase(resourceName) ?
isFoundExpandItem(type, matched, resource) : false;
expandItem = getMatchedExpandItem(propertyName, item, matched, resourceParts.get(resourceParts.size() - 2));
}
} else {
resource = resourceParts.get(resourceParts.size() - 2);
matched = resource.getSegmentValue().equalsIgnoreCase(resourceName) ?
isFoundExpandItem(type, matched, resource) : false;
expandItem = getMatchedExpandItem(propertyName, item, matched, resourceParts.get(resourceParts.size() - 1));
}
if (expandItem != null) {
return expandItem;
}
}
return expandItem;
}
/**
* @param propertyName
* @param item
* @param matched
* @param resource
*/
private static ExpandItem getMatchedExpandItem(final String propertyName, final ExpandItem item, boolean matched,
UriResource resource) {
if (matched && ((resource instanceof UriResourceNavigation
&& propertyName.equals(((UriResourceNavigation) resource).getProperty().getName())) ||
resource instanceof UriResourceProperty
&& propertyName.equals(((UriResourceProperty) resource).getProperty().getName()))) {
return item;
}
return null;
}
/**
* @param type
* @param matched
* @param resource
* @return
*/
private static boolean isFoundExpandItem(final EdmStructuredType type,
boolean matched, UriResource resource) {
if (!matched) {
if ((resource instanceof UriResourceProperty &&
type.compatibleTo(((UriResourceProperty) resource).getType())) ||
(resource instanceof UriResourceNavigation &&
type.compatibleTo(((UriResourceNavigation) resource).getType()))) {
matched = true;
}
}
return matched;
}
} }

View File

@ -32,11 +32,11 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamWriter;
import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.AbstractEntityCollection;
import org.apache.olingo.commons.api.data.ComplexValue; import org.apache.olingo.commons.api.data.ComplexValue;
import org.apache.olingo.commons.api.data.ContextURL; import org.apache.olingo.commons.api.data.ContextURL;
import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.data.EntityCollection;
import org.apache.olingo.commons.api.data.AbstractEntityCollection;
import org.apache.olingo.commons.api.data.EntityIterator; import org.apache.olingo.commons.api.data.EntityIterator;
import org.apache.olingo.commons.api.data.Link; import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Linked; import org.apache.olingo.commons.api.data.Linked;
@ -527,7 +527,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
} }
writer.writeStartElement(METADATA, Constants.PROPERTIES, NS_METADATA); writer.writeStartElement(METADATA, Constants.PROPERTIES, NS_METADATA);
writeProperties(metadata, resolvedType, entity.getProperties(), select, xml10InvalidCharReplacement, writer); writeProperties(metadata, resolvedType, entity.getProperties(), select,
xml10InvalidCharReplacement, writer, entity, expand);
writer.writeEndElement(); // properties writer.writeEndElement(); // properties
if (!entityType.hasStream()) { // content if (!entityType.hasStream()) { // content
@ -626,18 +627,21 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type, protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type,
final List<Property> properties, final SelectOption select, final String xml10InvalidCharReplacement, final List<Property> properties, final SelectOption select, final String xml10InvalidCharReplacement,
final XMLStreamWriter writer) throws XMLStreamException, SerializerException { final XMLStreamWriter writer, Linked linked, ExpandOption expand)
throws XMLStreamException, SerializerException {
final boolean all = ExpandSelectHelper.isAll(select); final boolean all = ExpandSelectHelper.isAll(select);
final Set<String> selected = all ? new HashSet<String>() : final Set<String> selected = all ? new HashSet<String>() :
ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems()); ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
addKeyPropertiesToSelected(selected, type); addKeyPropertiesToSelected(selected, type);
Set<List<String>> expandedPaths = ExpandSelectHelper.getExpandedItemsPath(expand);
for (final String propertyName : type.getPropertyNames()) { for (final String propertyName : type.getPropertyNames()) {
if (all || selected.contains(propertyName)) { if (all || selected.contains(propertyName)) {
final EdmProperty edmProperty = type.getStructuralProperty(propertyName); final EdmProperty edmProperty = type.getStructuralProperty(propertyName);
final Property property = findProperty(propertyName, properties); final Property property = findProperty(propertyName, properties);
final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null :
ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName); ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName);
writeProperty(metadata, edmProperty, property, selectedPaths, xml10InvalidCharReplacement, writer); writeProperty(metadata, edmProperty, property, selectedPaths,
xml10InvalidCharReplacement, writer, expandedPaths, linked, expand);
} }
} }
} }
@ -660,7 +664,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
if ((toDepth != null && toDepth > 1) || (toDepth == null && ExpandSelectHelper.hasExpand(expand))) { if ((toDepth != null && toDepth > 1) || (toDepth == null && ExpandSelectHelper.hasExpand(expand))) {
final ExpandItem expandAll = ExpandSelectHelper.getExpandAll(expand); final ExpandItem expandAll = ExpandSelectHelper.getExpandAll(expand);
for (final String propertyName : type.getNavigationPropertyNames()) { for (final String propertyName : type.getNavigationPropertyNames()) {
final ExpandItem innerOptions = ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName); final ExpandItem innerOptions = ExpandSelectHelper.getExpandItemBasedOnType(expand.getExpandItems(),
propertyName, type, name);
if (expandAll != null || innerOptions != null || toDepth != null) { if (expandAll != null || innerOptions != null || toDepth != null) {
Integer levels = null; Integer levels = null;
final EdmNavigationProperty property = type.getNavigationProperty(propertyName); final EdmNavigationProperty property = type.getNavigationProperty(propertyName);
@ -782,7 +787,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
protected void writeProperty(final ServiceMetadata metadata, protected void writeProperty(final ServiceMetadata metadata,
final EdmProperty edmProperty, final Property property, final EdmProperty edmProperty, final Property property,
final Set<List<String>> selectedPaths, final Set<List<String>> selectedPaths,
final String xml10InvalidCharReplacement, final XMLStreamWriter writer) final String xml10InvalidCharReplacement, final XMLStreamWriter writer,
Set<List<String>> expandedPaths, Linked linked, ExpandOption expand)
throws XMLStreamException, SerializerException { throws XMLStreamException, SerializerException {
writer.writeStartElement(DATA, edmProperty.getName(), NS_DATA); writer.writeStartElement(DATA, edmProperty.getName(), NS_DATA);
if (property == null || property.isNull()) { if (property == null || property.isNull()) {
@ -793,7 +799,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
SerializerException.MessageKeys.MISSING_PROPERTY, edmProperty.getName()); SerializerException.MessageKeys.MISSING_PROPERTY, edmProperty.getName());
} }
} else { } else {
writePropertyValue(metadata, edmProperty, property, selectedPaths, xml10InvalidCharReplacement, writer); writePropertyValue(metadata, edmProperty, property, selectedPaths,
xml10InvalidCharReplacement, writer, expandedPaths, linked, expand);
} }
writer.writeEndElement(); writer.writeEndElement();
} }
@ -820,7 +827,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
private void writePropertyValue(final ServiceMetadata metadata, private void writePropertyValue(final ServiceMetadata metadata,
final EdmProperty edmProperty, final Property property, final EdmProperty edmProperty, final Property property,
final Set<List<String>> selectedPaths, final Set<List<String>> selectedPaths,
final String xml10InvalidCharReplacement, final XMLStreamWriter writer) final String xml10InvalidCharReplacement, final XMLStreamWriter writer,
Set<List<String>> expandedPaths, Linked linked, ExpandOption expand)
throws XMLStreamException, SerializerException { throws XMLStreamException, SerializerException {
try { try {
if (edmProperty.isPrimitive() if (edmProperty.isPrimitive()
@ -845,9 +853,10 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
if (edmProperty.isCollection()) { if (edmProperty.isCollection()) {
writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE, collectionType(edmProperty.getType())); writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE, collectionType(edmProperty.getType()));
writeComplexCollection(metadata, (EdmComplexType) edmProperty.getType(), property, selectedPaths, writeComplexCollection(metadata, (EdmComplexType) edmProperty.getType(), property, selectedPaths,
xml10InvalidCharReplacement, writer); xml10InvalidCharReplacement, writer, expandedPaths, linked, expand);
} else { } else {
writeComplex(metadata, edmProperty, property, selectedPaths, xml10InvalidCharReplacement, writer); writeComplex(metadata, edmProperty, property, selectedPaths,
xml10InvalidCharReplacement, writer, expandedPaths, linked, expand);
} }
} else { } else {
throw new SerializerException("Property type not yet supported!", throw new SerializerException("Property type not yet supported!",
@ -863,7 +872,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
private void writeComplex(final ServiceMetadata metadata, private void writeComplex(final ServiceMetadata metadata,
final EdmProperty edmProperty, final Property property, final EdmProperty edmProperty, final Property property,
final Set<List<String>> selectedPaths, final Set<List<String>> selectedPaths,
final String xml10InvalidCharReplacement, final XMLStreamWriter writer) final String xml10InvalidCharReplacement, final XMLStreamWriter writer,
Set<List<String>> expandedPaths, Linked linked, ExpandOption expand)
throws XMLStreamException, SerializerException{ throws XMLStreamException, SerializerException{
writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE, writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE,
@ -873,8 +883,24 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
final EdmComplexType resolvedType = resolveComplexType(metadata, final EdmComplexType resolvedType = resolveComplexType(metadata,
(EdmComplexType) edmProperty.getType(), derivedName); (EdmComplexType) edmProperty.getType(), derivedName);
if (null != linked) {
if (linked instanceof Entity) {
linked = ((Entity)linked).getProperty(property.getName()).asComplex();
} else if (linked instanceof ComplexValue) {
List<Property> complexProperties = ((ComplexValue)linked).getValue();
for (Property prop : complexProperties) {
if (prop.getName().equals(property.getName())) {
linked = prop.asComplex();
break;
}
}
}
expandedPaths = expandedPaths == null || expandedPaths.isEmpty() ? null :
ExpandSelectHelper.getReducedExpandItemsPaths(expandedPaths, property.getName());
}
writeComplexValue(metadata, resolvedType, property.asComplex().getValue(), writeComplexValue(metadata, resolvedType, property.asComplex().getValue(),
selectedPaths, xml10InvalidCharReplacement, writer); selectedPaths, xml10InvalidCharReplacement, writer, expandedPaths, linked, expand, property.getName());
} }
private void writePrimitiveCollection(final EdmPrimitiveType type, final Property property, private void writePrimitiveCollection(final EdmPrimitiveType type, final Property property,
final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
@ -901,10 +927,14 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
private void writeComplexCollection(final ServiceMetadata metadata, private void writeComplexCollection(final ServiceMetadata metadata,
final EdmComplexType type, final Property property, final Set<List<String>> selectedPaths, final EdmComplexType type, final Property property, final Set<List<String>> selectedPaths,
final String xml10InvalidCharReplacement, final XMLStreamWriter writer) final String xml10InvalidCharReplacement, final XMLStreamWriter writer,
Set<List<String>> expandedPaths, Linked linked, ExpandOption expand)
throws XMLStreamException, SerializerException { throws XMLStreamException, SerializerException {
EdmComplexType complexType = type; EdmComplexType complexType = type;
Set<List<String>> expandedPaths1 = expandedPaths != null && !expandedPaths.isEmpty() ?
expandedPaths : ExpandSelectHelper.getExpandedItemsPath(expand);
for (Object value : property.asCollection()) { for (Object value : property.asCollection()) {
expandedPaths = expandedPaths1;
writer.writeStartElement(METADATA, Constants.ELEM_ELEMENT, NS_METADATA); writer.writeStartElement(METADATA, Constants.ELEM_ELEMENT, NS_METADATA);
String typeName = ((ComplexValue)value).getTypeName(); String typeName = ((ComplexValue)value).getTypeName();
String propertyType = typeName != null ? typeName :property.getType(); String propertyType = typeName != null ? typeName :property.getType();
@ -918,9 +948,11 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
} }
switch (property.getValueType()) { switch (property.getValueType()) {
case COLLECTION_COMPLEX: case COLLECTION_COMPLEX:
expandedPaths = expandedPaths == null || expandedPaths.isEmpty() ? null :
ExpandSelectHelper.getReducedExpandItemsPaths(expandedPaths, property.getName());
writeComplexValue(metadata, complexType, writeComplexValue(metadata, complexType,
((ComplexValue) value).getValue(), selectedPaths, ((ComplexValue) value).getValue(), selectedPaths,
xml10InvalidCharReplacement, writer); xml10InvalidCharReplacement, writer, expandedPaths, (ComplexValue) value, expand, property.getName());
break; break;
default: default:
throw new SerializerException("Property type not yet supported!", throw new SerializerException("Property type not yet supported!",
@ -975,16 +1007,27 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
protected void writeComplexValue(final ServiceMetadata metadata, protected void writeComplexValue(final ServiceMetadata metadata,
final EdmComplexType type, final List<Property> properties, final EdmComplexType type, final List<Property> properties,
final Set<List<String>> selectedPaths, final String xml10InvalidCharReplacement, final Set<List<String>> selectedPaths, final String xml10InvalidCharReplacement,
final XMLStreamWriter writer) throws XMLStreamException, SerializerException { final XMLStreamWriter writer, Set<List<String>> expandedPaths,
Linked linked, ExpandOption expand, String complexPropName) throws XMLStreamException, SerializerException {
if (null != expandedPaths) {
for(List<String> paths : expandedPaths) {
if (!paths.isEmpty() && paths.size() == 1) {
expandedPaths = ExpandSelectHelper.getReducedExpandItemsPaths(expandedPaths, paths.get(0));
}
}
}
for (final String propertyName : type.getPropertyNames()) { for (final String propertyName : type.getPropertyNames()) {
final Property property = findProperty(propertyName, properties); final Property property = findProperty(propertyName, properties);
if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths, propertyName)) { if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths, propertyName)) {
writeProperty(metadata, (EdmProperty) type.getProperty(propertyName), property, writeProperty(metadata, (EdmProperty) type.getProperty(propertyName), property,
selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths, propertyName), selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths, propertyName),
xml10InvalidCharReplacement, writer); xml10InvalidCharReplacement, writer, expandedPaths, linked, expand);
} }
} }
writeNavigationProperties(metadata, type, linked,
expand, null, xml10InvalidCharReplacement, null, complexPropName, writer);
} }
private Property findProperty(final String propertyName, final List<Property> properties) { private Property findProperty(final String propertyName, final List<Property> properties) {
@ -1082,6 +1125,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
writer.writeStartElement(METADATA, Constants.VALUE, NS_METADATA); writer.writeStartElement(METADATA, Constants.VALUE, NS_METADATA);
writer.writeNamespace(METADATA, NS_METADATA); writer.writeNamespace(METADATA, NS_METADATA);
writer.writeNamespace(DATA, NS_DATA); writer.writeNamespace(DATA, NS_DATA);
writer.writeNamespace(ATOM, NS_ATOM);
writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE, writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE,
"#" + resolvedType.getFullQualifiedName().getFullQualifiedNameAsString()); "#" + resolvedType.getFullQualifiedName().getFullQualifiedNameAsString());
writer.writeAttribute(METADATA, NS_METADATA, Constants.CONTEXT, writer.writeAttribute(METADATA, NS_METADATA, Constants.CONTEXT,
@ -1094,7 +1138,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
writeProperties(metadata, resolvedType, values, writeProperties(metadata, resolvedType, values,
options == null ? null : options.getSelect(), options == null ? null : options.getSelect(),
options == null ? null : options.xml10InvalidCharReplacement(), options == null ? null : options.xml10InvalidCharReplacement(),
writer); writer, property.asComplex(), options == null ? null : options.getExpand());
} }
writer.writeEndDocument(); writer.writeEndDocument();
writer.flush(); writer.flush();
@ -1184,6 +1228,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
writer.writeStartElement(METADATA, Constants.VALUE, NS_METADATA); writer.writeStartElement(METADATA, Constants.VALUE, NS_METADATA);
writer.writeNamespace(METADATA, NS_METADATA); writer.writeNamespace(METADATA, NS_METADATA);
writer.writeNamespace(DATA, NS_DATA); writer.writeNamespace(DATA, NS_DATA);
writer.writeNamespace(ATOM, NS_ATOM);
writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE, collectionType(type)); writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE, collectionType(type));
writer.writeAttribute(METADATA, NS_METADATA, Constants.CONTEXT, writer.writeAttribute(METADATA, NS_METADATA, Constants.CONTEXT,
ContextURLBuilder.create(contextURL).toASCIIString()); ContextURLBuilder.create(contextURL).toASCIIString());
@ -1194,8 +1239,14 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
selectedPaths = all || property.isPrimitive() ? null : ExpandSelectHelper selectedPaths = all || property.isPrimitive() ? null : ExpandSelectHelper
.getSelectedPaths(options.getSelect().getSelectItems()); .getSelectedPaths(options.getSelect().getSelectItems());
} }
Set<List<String>> expandPaths = null;
if (null != options && null != options.getExpand()) {
expandPaths = ExpandSelectHelper.getExpandedItemsPath(options.getExpand());
}
writeComplexCollection(metadata, type, property, selectedPaths, writeComplexCollection(metadata, type, property, selectedPaths,
options == null ? null:options.xml10InvalidCharReplacement(), writer); options == null ? null:options.xml10InvalidCharReplacement(), writer, expandPaths, null,
options == null ? null : options.getExpand());
writer.writeEndElement(); writer.writeEndElement();
writer.writeEndDocument(); writer.writeEndDocument();
writer.flush(); writer.flush();

View File

@ -194,7 +194,7 @@ public class ExpandParser {
String name = null; String name = null;
while (tokenizer.next(TokenKind.ODataIdentifier)) { while (tokenizer.next(TokenKind.ODataIdentifier)) {
name = tokenizer.getText(); name = tokenizer.getText();
final EdmProperty property = referencedType.getStructuralProperty(name); final EdmProperty property = type.getStructuralProperty(name);
if (property != null && property.getType().getKind() == EdmTypeKind.COMPLEX) { if (property != null && property.getType().getKind() == EdmTypeKind.COMPLEX) {
type = (EdmStructuredType) property.getType(); type = (EdmStructuredType) property.getType();
UriResourceComplexPropertyImpl complexResource = new UriResourceComplexPropertyImpl(property); UriResourceComplexPropertyImpl complexResource = new UriResourceComplexPropertyImpl(property);

View File

@ -203,15 +203,15 @@ public class ActionData {
final Parameter paramInt16 = parameters.get("ParameterInt16"); final Parameter paramInt16 = parameters.get("ParameterInt16");
final Short number = paramInt16 == null || paramInt16.isNull() ? 0 : (Short) paramInt16.asPrimitive(); final Short number = paramInt16 == null || paramInt16.isNull() ? 0 : (Short) paramInt16.asPrimitive();
if (number >= 1) { if (number >= 1) {
complexCollection.add(createCTTwoPrimComplexProperty(null, (short) 16, "Test123").asComplex()); complexCollection.add(createCTTwoPrimComplexProperty("PropertyComp", (short) 16, "Test123").asComplex());
} }
if (number >= 2) { if (number >= 2) {
complexCollection.add(createCTTwoPrimComplexProperty(null, (short) 17, "Test456").asComplex()); complexCollection.add(createCTTwoPrimComplexProperty("PropertyComp", (short) 17, "Test456").asComplex());
} }
if (number >= 3) { if (number >= 3) {
complexCollection.add(createCTTwoPrimComplexProperty(null, (short) 18, "Test678").asComplex()); complexCollection.add(createCTTwoPrimComplexProperty("PropertyComp", (short) 18, "Test678").asComplex());
} }
return new Property(null, name, ValueType.COLLECTION_COMPLEX, complexCollection); return new Property("PropertyCollComp", name, ValueType.COLLECTION_COMPLEX, complexCollection);
} }
throw new DataProviderException("Action " + name + " is not yet implemented.", throw new DataProviderException("Action " + name + " is not yet implemented.",
HttpStatusCode.NOT_IMPLEMENTED); HttpStatusCode.NOT_IMPLEMENTED);

View File

@ -110,8 +110,122 @@ public class DataCreator {
linkESDelta(data); linkESDelta(data);
linkESKeyNavCont(data); linkESKeyNavCont(data);
linkETBaseCont(data); linkETBaseCont(data);
linkPropCompInESCompMixPrimCollCompToETTwoKeyNav(data);
linkCollPropCompInESCompMixPrimCollCompToETTwoKeyNav(data);
linkPropCompInESCompMixPrimCollCompToETMedia(data);
linkPropMixPrimCompInESCompMixPrimCollCompToETTwoKeyNav(data);
linkPropMixPrimCompInESCompMixPrimCollCompToCollETTwoKeyNav(data);
linkColPropCompInESMixPrimCollCompToETTwoKeyNav(data);
} }
@SuppressWarnings("unchecked")
private void linkCollPropCompInESCompMixPrimCollCompToETTwoKeyNav(Map<String, EntityCollection> data2) {
EntityCollection collection = data.get("ESCompMixPrimCollComp");
Entity entity = collection.getEntities().get(0);
ComplexValue complexValue = entity.getProperties().get(1).asComplex();
List<ComplexValue> innerComplexValue = (List<ComplexValue>) complexValue.getValue().get(3).asCollection();
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
for (ComplexValue innerValue : innerComplexValue) {
Link link = new Link();
link.setRel(Constants.NS_NAVIGATION_LINK_REL + "NavPropertyETTwoKeyNavOne");
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
link.setTitle("NavPropertyETTwoKeyNavOne");
link.setHref(esTwoKeyNavTargets.get(1).getId().toASCIIString());
innerValue.getNavigationLinks().add(link);
link.setInlineEntity(esTwoKeyNavTargets.get(1));
}
}
@SuppressWarnings("unchecked")
private void linkColPropCompInESMixPrimCollCompToETTwoKeyNav(Map<String, EntityCollection> data2) {
EntityCollection collection = data.get("ESMixPrimCollComp");
Entity entity = collection.getEntities().get(0);
List<ComplexValue> list = (List<ComplexValue>) entity.getProperties().get(3).asCollection();
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
for (ComplexValue complexValue : list) {
Link link = new Link();
link.setRel(Constants.NS_NAVIGATION_LINK_REL + "NavPropertyETTwoKeyNavOne");
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
link.setTitle("NavPropertyETTwoKeyNavOne");
link.setHref(esTwoKeyNavTargets.get(1).getId().toASCIIString());
complexValue.getNavigationLinks().add(link);
link.setInlineEntity(esTwoKeyNavTargets.get(1));
}
ComplexValue complexValue = (ComplexValue) entity.getProperties().get(2).asComplex();
Link link = new Link();
link.setRel(Constants.NS_NAVIGATION_LINK_REL + "NavPropertyETTwoKeyNavOne");
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
link.setTitle("NavPropertyETTwoKeyNavOne");
link.setHref(esTwoKeyNavTargets.get(0).getId().toASCIIString());
complexValue.getNavigationLinks().add(link);
link.setInlineEntity(esTwoKeyNavTargets.get(0));
}
private void linkPropMixPrimCompInESCompMixPrimCollCompToETTwoKeyNav(
Map<String, EntityCollection> data) {
EntityCollection collection = data.get("ESCompMixPrimCollComp");
Entity entity = collection.getEntities().get(0);
ComplexValue complexValue = entity.getProperties().get(1).asComplex();
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
Link link = new Link();
link.setRel(Constants.NS_NAVIGATION_LINK_REL + "NavPropertyETTwoKeyNavOne");
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
link.setTitle("NavPropertyETTwoKeyNavOne");
link.setInlineEntity(esTwoKeyNavTargets.get(1));
link.setHref(esTwoKeyNavTargets.get(1).getId().toASCIIString());
complexValue.getNavigationLinks().add(link);
}
private void linkPropMixPrimCompInESCompMixPrimCollCompToCollETTwoKeyNav(
Map<String, EntityCollection> data) {
EntityCollection collection = data.get("ESCompMixPrimCollComp");
Entity entity = collection.getEntities().get(0);
ComplexValue complexValue = entity.getProperties().get(1).asComplex();
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
Link link = new Link();
link.setRel(Constants.NS_NAVIGATION_LINK_REL + "NavPropertyETTwoKeyNavMany");
link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
link.setTitle("NavPropertyETTwoKeyNavMany");
EntityCollection target = new EntityCollection();
target.setCount(2);
target.getEntities().addAll(Arrays.asList(esTwoKeyNavTargets.get(0), esTwoKeyNavTargets.get(2)));
link.setInlineEntitySet(target);
link.setHref(entity.getId().toASCIIString() + "/" +
entity.getProperties().get(1).getName() + "/"
+ "NavPropertyETTwoKeyNavMany");
complexValue.getNavigationLinks().add(link);
}
private void linkPropCompInESCompMixPrimCollCompToETMedia(Map<String, EntityCollection> data) {
EntityCollection collection = data.get("ESCompMixPrimCollComp");
Entity entity = collection.getEntities().get(0);
ComplexValue complexValue = entity.getProperties().get(1).asComplex();
ComplexValue innerComplexValue = complexValue.getValue().get(2).asComplex();
final List<Entity> esMediaTargets = data.get("ESMedia").getEntities();
Link link = new Link();
link.setRel(Constants.NS_NAVIGATION_LINK_REL + "NavPropertyETMediaOne");
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
link.setTitle("NavPropertyETMediaOne");
link.setHref(esMediaTargets.get(1).getId().toASCIIString());
innerComplexValue.getNavigationLinks().add(link);
link.setInlineEntity(esMediaTargets.get(1));
}
private void linkPropCompInESCompMixPrimCollCompToETTwoKeyNav(Map<String, EntityCollection> data) {
EntityCollection collection = data.get("ESCompMixPrimCollComp");
Entity entity = collection.getEntities().get(0);
ComplexValue complexValue = entity.getProperties().get(1).asComplex();
ComplexValue innerComplexValue = complexValue.getValue().get(2).asComplex();
final List<Entity> esTwoKeyNavTargets = data.get("ESTwoKeyNav").getEntities();
Link link = new Link();
link.setRel(Constants.NS_NAVIGATION_LINK_REL + "NavPropertyETTwoKeyNavOne");
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
link.setTitle("NavPropertyETTwoKeyNavOne");
link.setHref(esTwoKeyNavTargets.get(1).getId().toASCIIString());
innerComplexValue.getNavigationLinks().add(link);
link.setInlineEntity(esTwoKeyNavTargets.get(1));
}
private EntityCollection createESDelta(final Edm edm, final OData odata) { private EntityCollection createESDelta(final Edm edm, final OData odata) {
EntityCollection entityCollection = new EntityCollection(); EntityCollection entityCollection = new EntityCollection();
@ -181,7 +295,7 @@ public class DataCreator {
ComplexTypeProvider.nameCTTwoPrimAno.getFullQualifiedNameAsString(), ComplexTypeProvider.nameCTTwoPrimAno.getFullQualifiedNameAsString(),
Arrays.asList(new ComplexValue[] { Arrays.asList(new ComplexValue[] {
createComplexValue(ComplexTypeProvider.nameCTBaseAno.getFullQualifiedNameAsString(), createComplexValue(ComplexTypeProvider.nameCTBaseAno.getFullQualifiedNameAsString(),
Arrays.asList(new Property[] { "CollPropertyCompAno", Arrays.asList(new Property[] {
createDerived("AdditionalPropString", createDerived("AdditionalPropString",
ComplexTypeProvider.nameCTBaseAno.getFullQualifiedNameAsString(), ComplexTypeProvider.nameCTBaseAno.getFullQualifiedNameAsString(),
"Additional12345"), "Additional12345"),
@ -191,7 +305,7 @@ public class DataCreator {
} }
)), )),
createComplexValue(ComplexTypeProvider.nameCTTwoPrimAno.getFullQualifiedNameAsString(), createComplexValue(ComplexTypeProvider.nameCTTwoPrimAno.getFullQualifiedNameAsString(),
Arrays.asList(new Property[] { "CollPropertyCompAno", Arrays.asList(new Property[] {
createDerived("PropertyString", createDerived("PropertyString",
ComplexTypeProvider.nameCTTwoPrimAno.getFullQualifiedNameAsString(), ComplexTypeProvider.nameCTTwoPrimAno.getFullQualifiedNameAsString(),
"TESTabcd") "TESTabcd")
@ -206,10 +320,11 @@ public class DataCreator {
return entityCollection; return entityCollection;
} }
private ComplexValue createComplexValue(String type, List<Property> properties) { private ComplexValue createComplexValue(String type, String name, List<Property> properties) {
ComplexValue complexValue = new ComplexValue(); ComplexValue complexValue = new ComplexValue();
complexValue.getValue().addAll(properties); complexValue.getValue().addAll(properties);
complexValue.setTypeName(type); complexValue.setTypeName(type);
complexValue.setId(URI.create(name));
return complexValue; return complexValue;
} }
@ -1416,19 +1531,19 @@ public class DataCreator {
ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(), ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(),
Arrays.asList(new ComplexValue[] { Arrays.asList(new ComplexValue[] {
createComplexValue(ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(), createComplexValue(ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(),
Arrays.asList(new Property[] { "CollPropertyComp", Arrays.asList(new Property[] {
createPrimitive("PropertyInt16", (short) 123), createPrimitive("PropertyInt16", (short) 123),
createPrimitive("PropertyString", "TEST 1") createPrimitive("PropertyString", "TEST 1")
} }
)), )),
createComplexValue(ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(), createComplexValue(ComplexTypeProvider.nameCTTwoPrim.getFullQualifiedNameAsString(),
Arrays.asList(new Property[] { "CollPropertyComp", Arrays.asList(new Property[] {
createPrimitive("PropertyInt16", (short) 456), createPrimitive("PropertyInt16", (short) 456),
createPrimitive("PropertyString", "TEST 2") createPrimitive("PropertyString", "TEST 2")
} }
)), )),
createComplexValue(ComplexTypeProvider.nameCTBase.getFullQualifiedNameAsString(), createComplexValue(ComplexTypeProvider.nameCTBase.getFullQualifiedNameAsString(),
Arrays.asList(new Property[] { "CollPropertyComp", Arrays.asList(new Property[] {
createPrimitive("PropertyInt16", (short) 789), createPrimitive("PropertyInt16", (short) 789),
createPrimitive("PropertyString", "TEST 3"), createPrimitive("PropertyString", "TEST 3"),
createPrimitive("AdditionalPropString", "ADD TEST") createPrimitive("AdditionalPropString", "ADD TEST")
@ -1753,6 +1868,9 @@ public class DataCreator {
for (final Property property : properties) { for (final Property property : properties) {
complexValue.getValue().add(property); complexValue.getValue().add(property);
} }
if (null != name) {
complexValue.setId(URI.create(name));
}
Property property = new Property(type, name, ValueType.COMPLEX, complexValue); Property property = new Property(type, name, ValueType.COMPLEX, complexValue);
createOperations(name, type, property); createOperations(name, type, property);
return property; return property;
@ -1784,6 +1902,9 @@ public class DataCreator {
for (final List<Property> properties : propertiesList) { for (final List<Property> properties : propertiesList) {
ComplexValue complexValue = new ComplexValue(); ComplexValue complexValue = new ComplexValue();
complexValue.getValue().addAll(properties); complexValue.getValue().addAll(properties);
if (null != name) {
complexValue.setId(URI.create(name));
}
complexCollection.add(complexValue); complexCollection.add(complexValue);
} }
Property property = new Property(type, name, ValueType.COLLECTION_COMPLEX, complexCollection); Property property = new Property(type, name, ValueType.COLLECTION_COMPLEX, complexCollection);

View File

@ -19,6 +19,7 @@
package org.apache.olingo.server.tecsvc.data; package org.apache.olingo.server.tecsvc.data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URI;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -164,6 +165,7 @@ public class FunctionData {
complexValue.getValue().add(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, counter++)); complexValue.getValue().add(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, counter++));
complexValue.getValue().add(new Property(null, "PropertyString", ValueType.PRIMITIVE, complexValue.getValue().add(new Property(null, "PropertyString", ValueType.PRIMITIVE,
name + " string value: " + parameterString)); name + " string value: " + parameterString));
complexValue.setId(URI.create(""));
complexValues.add(complexValue); complexValues.add(complexValue);
} }
return new Property(null, name, ValueType.COLLECTION_COMPLEX, complexValues); return new Property(null, name, ValueType.COLLECTION_COMPLEX, complexValues);

View File

@ -115,8 +115,12 @@ public class ComplexTypeProvider {
return new CsdlComplexType() return new CsdlComplexType()
.setName("CTTwoPrim") .setName("CTTwoPrim")
.setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable, .setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable,
PropertyProvider.propertyString_NotNullable)); PropertyProvider.propertyString_NotNullable))
.setNavigationProperties((Arrays.asList(
PropertyProvider.collectionNavPropertyETTwoKeyNavOne_ETTwoKeyNav,
new CsdlNavigationProperty()
.setName("NavPropertyETMediaOne")
.setType(EntityTypeProvider.nameETMedia))));
} else if (complexTypeName.equals(nameCTCompNav)) { } else if (complexTypeName.equals(nameCTCompNav)) {
return new CsdlComplexType() return new CsdlComplexType()
.setName("CTCompNav") .setName("CTCompNav")
@ -128,7 +132,10 @@ public class ComplexTypeProvider {
.setName("CTMixPrimCollComp") .setName("CTMixPrimCollComp")
.setProperties( .setProperties(
Arrays.asList(PropertyProvider.propertyInt16, PropertyProvider.collPropertyString, Arrays.asList(PropertyProvider.propertyInt16, PropertyProvider.collPropertyString,
PropertyProvider.propertyComp_CTTwoPrim, PropertyProvider.collPropertyComp_CTTwoPrim)); PropertyProvider.propertyComp_CTTwoPrim, PropertyProvider.collPropertyComp_CTTwoPrim))
.setNavigationProperties((Arrays.asList(
PropertyProvider.collectionNavPropertyETTwoKeyNavOne_ETTwoKeyNav,
PropertyProvider.collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav)));
} else if (complexTypeName.equals(nameCTBase)) { } else if (complexTypeName.equals(nameCTBase)) {
return new CsdlComplexType() return new CsdlComplexType()

View File

@ -1813,7 +1813,8 @@ public class ODataJsonSerializerTest {
"\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\"," + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\"," +
"\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\"," + "\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\"," +
"\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":111," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":111," +
"\"PropertyString\":\"TEST A\"}",resultString); "\"PropertyString\":\"TEST A\",\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":"
+ "\"ESTwoKeyNav(PropertyInt16=1,PropertyString='1')\"}",resultString);
} }
@Test @Test
@ -1870,13 +1871,16 @@ public class ODataJsonSerializerTest {
+ "\"@odata.type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\"," + "\"@odata.type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\","
+ "\"value\":[{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\"," + "\"value\":[{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":123," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":123,"
+ "\"PropertyString\":\"TEST 1\"}," + "\"PropertyString\":\"TEST 1\","
+ "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"},"
+ "{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\"," + "{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":456," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":456,"
+ "\"PropertyString\":\"TEST 2\"}," + "\"PropertyString\":\"TEST 2\","
+ "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"},"
+ "{\"@odata.type\":\"#olingo.odata.test1.CTBase\"," + "{\"@odata.type\":\"#olingo.odata.test1.CTBase\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":789," + "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":789,"
+ "\"PropertyString\":\"TEST 3\",\"AdditionalPropString\":\"ADD TEST\"}]}"; + "\"PropertyString\":\"TEST 3\",\"AdditionalPropString\":\"ADD TEST\","
+ "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"}]}";
Assert.assertEquals(expectedResult, resultString); Assert.assertEquals(expectedResult, resultString);
} }
@ -2700,4 +2704,76 @@ public class ODataJsonSerializerTest {
+ "\"PropertyInt16\":1,\"PropertyString\":\"1\",\"CollPropertyCompNav\":[{}]}"; + "\"PropertyInt16\":1,\"PropertyString\":\"1\",\"CollPropertyCompNav\":[{}]}";
Assert.assertEquals(expectedResult, resultString); Assert.assertEquals(expectedResult, resultString);
} }
@Test
public void entityWithExtendedComplexTypeWithMetadata() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompMixPrimCollComp");
final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
final String resultString = IOUtils.toString(serializerFullMetadata
.entity(metadata, edmEntitySet.getEntityType(), entity,
EntitySerializerOptions.with()
.contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
.build()).getContent());
final String expectedResult = "{\"@odata.context\":\"$metadata#ESCompMixPrimCollComp/$entity\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@odata.type\":\"#olingo.odata.test1.ETCompMixPrimCollComp\","
+ "\"@odata.id\":\"ESCompMixPrimCollComp(1)\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":1,"
+ "\"PropertyMixedPrimCollComp\":"
+ "{\"@odata.type\":\"#olingo.odata.test1.CTMixPrimCollComp\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":1,"
+ "\"CollPropertyString@odata.type\":\"#Collection(String)\","
+ "\"CollPropertyString\":[\"Employee1@company.example\","
+ "\"Employee2@company.example\",\"Employee3@company.example\"],"
+ "\"PropertyComp\":{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":333,"
+ "\"PropertyString\":\"TEST123\","
+ "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":"
+ "\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\","
+ "\"NavPropertyETMediaOne@odata.navigationLink\":\"ESMedia(2)\"},"
+ "\"CollPropertyComp@odata.type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\","
+ "\"CollPropertyComp\":[{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":222,"
+ "\"PropertyString\":\"TEST9876\","
+ "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"},"
+ "{\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":333,"
+ "\"PropertyString\":\"TEST123\","
+ "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"}],"
+ "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":"
+ "\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\","
+ "\"NavPropertyETTwoKeyNavMany@odata.navigationLink\":"
+ "\"ESCompMixPrimCollComp(1)/PropertyMixedPrimCollComp/NavPropertyETTwoKeyNavMany\"}}";
Assert.assertEquals(expectedResult, resultString);
}
@Test
public void extendedcomplexPropertyWithNavWithMetadataFull() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompMixPrimCollComp");
final EdmProperty edmComplexType = (EdmProperty) edmEntitySet.getEntityType().
getProperty("PropertyMixedPrimCollComp");
final EdmComplexType complexType = metadata.getEdm().getComplexType(
new FullQualifiedName("olingo.odata.test1", "CTMixPrimCollComp"));
EdmProperty edmProperty = (EdmProperty) complexType.getProperty("PropertyComp");
final ComplexValue complexValue = data.readAll(edmEntitySet).getEntities().get(0).
getProperty("PropertyMixedPrimCollComp").asComplex();
final Property property = complexValue.getValue().get(2);
final String resultString = IOUtils.toString(serializerFullMetadata
.complex(metadata, (EdmComplexType) edmProperty.getType(), property,
ComplexSerializerOptions.with()
.contextURL(ContextURL.with()
.entitySet(edmEntitySet).keyPath("1")
.navOrPropertyPath(edmComplexType.getName()+"/"+property.getName())
.build()).build()).getContent());
Assert.assertEquals("{\"@odata.context\":\"$metadata#ESCompMixPrimCollComp(1)/"
+ "PropertyMixedPrimCollComp/PropertyComp\",\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@odata.type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@odata.type\":\"#Int16\",\"PropertyInt16\":333,"
+ "\"PropertyString\":\"TEST123\","
+ "\"NavPropertyETTwoKeyNavOne@odata.navigationLink\":"
+ "\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\","
+ "\"NavPropertyETMediaOne@odata.navigationLink\":\"ESMedia(2)\"}",resultString);
}
} }

View File

@ -1826,7 +1826,8 @@ public class ODataJsonSerializerv01Test {
"\"@metadataEtag\":\"W/\\\"metadataETag\\\"\"," + "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\"," +
"\"@type\":\"#olingo.odata.test1.CTTwoPrim\"," + "\"@type\":\"#olingo.odata.test1.CTTwoPrim\"," +
"\"PropertyInt16@type\":\"#Int16\",\"PropertyInt16\":111," + "\"PropertyInt16@type\":\"#Int16\",\"PropertyInt16\":111," +
"\"PropertyString\":\"TEST A\"}",resultString); "\"PropertyString\":\"TEST A\",\"NavPropertyETTwoKeyNavOne@navigationLink\":"
+ "\"ESTwoKeyNav(PropertyInt16=1,PropertyString='1')\"}",resultString);
} }
@Test @Test
@ -1883,13 +1884,16 @@ public class ODataJsonSerializerv01Test {
+ "\"@type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\"," + "\"@type\":\"#Collection(olingo.odata.test1.CTTwoPrim)\","
+ "\"value\":[{\"@type\":\"#olingo.odata.test1.CTTwoPrim\"," + "\"value\":[{\"@type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@type\":\"#Int16\",\"PropertyInt16\":123," + "\"PropertyInt16@type\":\"#Int16\",\"PropertyInt16\":123,"
+ "\"PropertyString\":\"TEST 1\"}," + "\"PropertyString\":\"TEST 1\","
+ "\"NavPropertyETTwoKeyNavOne@navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"},"
+ "{\"@type\":\"#olingo.odata.test1.CTTwoPrim\"," + "{\"@type\":\"#olingo.odata.test1.CTTwoPrim\","
+ "\"PropertyInt16@type\":\"#Int16\",\"PropertyInt16\":456," + "\"PropertyInt16@type\":\"#Int16\",\"PropertyInt16\":456,"
+ "\"PropertyString\":\"TEST 2\"}," + "\"PropertyString\":\"TEST 2\","
+ "\"NavPropertyETTwoKeyNavOne@navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"},"
+ "{\"@type\":\"#olingo.odata.test1.CTBase\"," + "{\"@type\":\"#olingo.odata.test1.CTBase\","
+ "\"PropertyInt16@type\":\"#Int16\",\"PropertyInt16\":789," + "\"PropertyInt16@type\":\"#Int16\",\"PropertyInt16\":789,"
+ "\"PropertyString\":\"TEST 3\",\"AdditionalPropString\":\"ADD TEST\"}]}"; + "\"PropertyString\":\"TEST 3\",\"AdditionalPropString\":\"ADD TEST\","
+ "\"NavPropertyETTwoKeyNavOne@navigationLink\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"}]}";
Assert.assertEquals(expectedResult, resultString); Assert.assertEquals(expectedResult, resultString);
} }

View File

@ -662,20 +662,44 @@ public class ODataXmlSerializerTest {
" <d:PropertyComp m:type=\"#olingo.odata.test1.CTTwoPrim\">\n" + " <d:PropertyComp m:type=\"#olingo.odata.test1.CTTwoPrim\">\n" +
" <d:PropertyInt16 m:type=\"Int16\">111</d:PropertyInt16>\n" + " <d:PropertyInt16 m:type=\"Int16\">111</d:PropertyInt16>\n" +
" <d:PropertyString>TEST A</d:PropertyString>\n" + " <d:PropertyString>TEST A</d:PropertyString>\n" +
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=entry\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"ESTwoKeyNav(PropertyInt16=1,PropertyString='1')\"/>\n" +
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"PropertyComp/NavPropertyETMediaOne\"/>\n" +
" </d:PropertyComp>\n" + " </d:PropertyComp>\n" +
" <d:CollPropertyComp m:type=\"#Collection(olingo.odata.test1.CTTwoPrim)\">\n" + " <d:CollPropertyComp m:type=\"#Collection(olingo.odata.test1.CTTwoPrim)\">\n" +
" <m:element>\n" + " <m:element>\n" +
" <d:PropertyInt16 m:type=\"Int16\">123</d:PropertyInt16>\n" + " <d:PropertyInt16 m:type=\"Int16\">123</d:PropertyInt16>\n" +
" <d:PropertyString>TEST 1</d:PropertyString>\n" + " <d:PropertyString>TEST 1</d:PropertyString>\n" +
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=entry\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"ESTwoKeyNav(PropertyInt16=1,PropertyString=&apos;2&apos;)\"/>\n" +
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
" </m:element>\n" + " </m:element>\n" +
" <m:element>\n" + " <m:element>\n" +
" <d:PropertyInt16 m:type=\"Int16\">456</d:PropertyInt16>\n" + " <d:PropertyInt16 m:type=\"Int16\">456</d:PropertyInt16>\n" +
" <d:PropertyString>TEST 2</d:PropertyString>\n" + " <d:PropertyString>TEST 2</d:PropertyString>\n" +
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=entry\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"ESTwoKeyNav(PropertyInt16=1,PropertyString=&apos;2&apos;)\"/>\n" +
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
" </m:element>\n" + " </m:element>\n" +
" <m:element m:type=\"olingo.odata.test1.CTBase\">\n" + " <m:element m:type=\"olingo.odata.test1.CTBase\">\n" +
" <d:PropertyInt16 m:type=\"Int16\">789</d:PropertyInt16>\n" + " <d:PropertyInt16 m:type=\"Int16\">789</d:PropertyInt16>\n" +
" <d:PropertyString>TEST 3</d:PropertyString>\n" + " <d:PropertyString>TEST 3</d:PropertyString>\n" +
" <d:AdditionalPropString>ADD TEST</d:AdditionalPropString>\n" + " <d:AdditionalPropString>ADD TEST</d:AdditionalPropString>\n" +
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=entry\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"ESTwoKeyNav(PropertyInt16=1,PropertyString=&apos;2&apos;)\"/>\n" +
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
" </m:element>\n" + " </m:element>\n" +
" </d:CollPropertyComp>\n" + " </d:CollPropertyComp>\n" +
" </m:properties>\n" + " </m:properties>\n" +
@ -1600,6 +1624,12 @@ public class ODataXmlSerializerTest {
"<d:PropertyCompComp m:type=\"#olingo.odata.test1.CTCompComp\">\n" + "<d:PropertyCompComp m:type=\"#olingo.odata.test1.CTCompComp\">\n" +
"<d:PropertyComp m:type=\"#olingo.odata.test1.CTBase\">\n" + "<d:PropertyComp m:type=\"#olingo.odata.test1.CTBase\">\n" +
"<d:PropertyString>Num111</d:PropertyString>\n" + "<d:PropertyString>Num111</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"PropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"PropertyComp/NavPropertyETMediaOne\"/>\n" +
"</d:PropertyComp>\n" + "</d:PropertyComp>\n" +
"</d:PropertyCompComp>\n" + "</d:PropertyCompComp>\n" +
"</m:properties>\n" + "</m:properties>\n" +
@ -1647,12 +1677,24 @@ public class ODataXmlSerializerTest {
"<d:PropertyComp m:type=\"#olingo.odata.test1.CTTwoPrim\">\n" + "<d:PropertyComp m:type=\"#olingo.odata.test1.CTTwoPrim\">\n" +
"<d:PropertyInt16 m:type=\"Int16\">11</d:PropertyInt16>\n" + "<d:PropertyInt16 m:type=\"Int16\">11</d:PropertyInt16>\n" +
"<d:PropertyString>Num11</d:PropertyString>\n" + "<d:PropertyString>Num11</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"PropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"PropertyComp/NavPropertyETMediaOne\"/>\n" +
"</d:PropertyComp>\n" + "</d:PropertyComp>\n" +
"<d:PropertyCompComp m:type=\"#olingo.odata.test1.CTCompComp\">\n" + "<d:PropertyCompComp m:type=\"#olingo.odata.test1.CTCompComp\">\n" +
"<d:PropertyComp m:type=\"#olingo.odata.test1.CTBase\">\n" + "<d:PropertyComp m:type=\"#olingo.odata.test1.CTBase\">\n" +
"<d:PropertyInt16 m:type=\"Int16\">111</d:PropertyInt16>\n" + "<d:PropertyInt16 m:type=\"Int16\">111</d:PropertyInt16>\n" +
"<d:PropertyString>Num111</d:PropertyString>\n" + "<d:PropertyString>Num111</d:PropertyString>\n" +
"<d:AdditionalPropString>Test123</d:AdditionalPropString>\n" + "<d:AdditionalPropString>Test123</d:AdditionalPropString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"PropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"PropertyComp/NavPropertyETMediaOne\"/>\n" +
"</d:PropertyComp>\n" + "</d:PropertyComp>\n" +
"</d:PropertyCompComp>\n" + "</d:PropertyCompComp>\n" +
"</m:properties>\n" + "</m:properties>\n" +
@ -1706,12 +1748,24 @@ public class ODataXmlSerializerTest {
" <d:PropertyInt16 m:type=\"Int16\">1</d:PropertyInt16>" + " <d:PropertyInt16 m:type=\"Int16\">1</d:PropertyInt16>" +
"<d:PropertyComp m:type=\"#olingo.odata.test1.CTTwoPrim\">\n" + "<d:PropertyComp m:type=\"#olingo.odata.test1.CTTwoPrim\">\n" +
"<d:PropertyString>Num11</d:PropertyString>\n" + "<d:PropertyString>Num11</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"PropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"PropertyComp/NavPropertyETMediaOne\"/>\n" +
"</d:PropertyComp>\n" + "</d:PropertyComp>\n" +
"<d:PropertyCompComp m:type=\"#olingo.odata.test1.CTCompComp\">\n" + "<d:PropertyCompComp m:type=\"#olingo.odata.test1.CTCompComp\">\n" +
"<d:PropertyComp m:type=\"#olingo.odata.test1.CTBase\">\n" + "<d:PropertyComp m:type=\"#olingo.odata.test1.CTBase\">\n" +
"<d:PropertyInt16 m:type=\"Int16\">111</d:PropertyInt16>\n" + "<d:PropertyInt16 m:type=\"Int16\">111</d:PropertyInt16>\n" +
"<d:PropertyString>Num111</d:PropertyString>\n" + "<d:PropertyString>Num111</d:PropertyString>\n" +
"<d:AdditionalPropString>Test123</d:AdditionalPropString>\n" + "<d:AdditionalPropString>Test123</d:AdditionalPropString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"PropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"PropertyComp/NavPropertyETMediaOne\"/>\n" +
"</d:PropertyComp>\n" + "</d:PropertyComp>\n" +
"</d:PropertyCompComp>\n" + "</d:PropertyCompComp>\n" +
"</m:properties>\n" + "</m:properties>\n" +
@ -1761,14 +1815,32 @@ public class ODataXmlSerializerTest {
"<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" + "<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" +
"<d:PropertyInt16 m:type=\"Int16\">555</d:PropertyInt16>\n" + "<d:PropertyInt16 m:type=\"Int16\">555</d:PropertyInt16>\n" +
"<d:PropertyString>1 Test Complex in Complex Property</d:PropertyString>\n" + "<d:PropertyString>1 Test Complex in Complex Property</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"CollPropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
"</m:element>\n" + "</m:element>\n" +
"<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" + "<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" +
"<d:PropertyInt16 m:type=\"Int16\">666</d:PropertyInt16>\n" + "<d:PropertyInt16 m:type=\"Int16\">666</d:PropertyInt16>\n" +
"<d:PropertyString>2 Test Complex in Complex Property</d:PropertyString>\n" + "<d:PropertyString>2 Test Complex in Complex Property</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"CollPropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
"</m:element>\n" + "</m:element>\n" +
"<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" + "<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" +
"<d:PropertyInt16 m:type=\"Int16\">777</d:PropertyInt16>\n" + "<d:PropertyInt16 m:type=\"Int16\">777</d:PropertyInt16>\n" +
"<d:PropertyString>3 Test Complex in Complex Property</d:PropertyString>\n" + "<d:PropertyString>3 Test Complex in Complex Property</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"CollPropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
"</m:element>\n" + "</m:element>\n" +
"</d:CollPropertyComp>\n" + "</d:CollPropertyComp>\n" +
"</d:PropertyComp>\n" + "</d:PropertyComp>\n" +
@ -1794,14 +1866,32 @@ public class ODataXmlSerializerTest {
"<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" + "<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" +
"<d:PropertyInt16 m:type=\"Int16\">888</d:PropertyInt16>\n" + "<d:PropertyInt16 m:type=\"Int16\">888</d:PropertyInt16>\n" +
"<d:PropertyString>11 Test Complex in Complex Property</d:PropertyString>\n" + "<d:PropertyString>11 Test Complex in Complex Property</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"CollPropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
"</m:element>\n" + "</m:element>\n" +
"<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" + "<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" +
"<d:PropertyInt16 m:type=\"Int16\">999</d:PropertyInt16>\n" + "<d:PropertyInt16 m:type=\"Int16\">999</d:PropertyInt16>\n" +
"<d:PropertyString>12 Test Complex in Complex Property</d:PropertyString>\n" + "<d:PropertyString>12 Test Complex in Complex Property</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"CollPropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
"</m:element>\n" + "</m:element>\n" +
"<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" + "<m:element m:type=\"olingo.odata.test1.CTCompCollComp\">\n" +
"<d:PropertyInt16 m:type=\"Int16\">0</d:PropertyInt16>\n" + "<d:PropertyInt16 m:type=\"Int16\">0</d:PropertyInt16>\n" +
"<d:PropertyString>13 Test Complex in Complex Property</d:PropertyString>\n" + "<d:PropertyString>13 Test Complex in Complex Property</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"CollPropertyComp/NavPropertyETTwoKeyNavOne\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
"</m:element>\n" + "</m:element>\n" +
"</d:CollPropertyComp>\n" + "</d:CollPropertyComp>\n" +
"</d:PropertyComp>\n" + "</d:PropertyComp>\n" +
@ -2666,22 +2756,40 @@ public class ODataXmlSerializerTest {
.build()).getContent()); .build()).getContent());
String expected = "<?xml version='1.0' encoding='UTF-8'?>\n" String expected = "<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<m:value xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" + + "<m:value xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
" xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" " " xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" xmlns:a=\"http://www.w3.org/2005/Atom\" "
+ "m:type=\"#Collection(olingo.odata.test1.CTTwoPrim)\"\n" + + "m:type=\"#Collection(olingo.odata.test1.CTTwoPrim)\"\n" +
" m:context=\"$metadata#ESMixPrimCollComp(32767)/CollPropertyComp\"\n" + " m:context=\"$metadata#ESMixPrimCollComp(32767)/CollPropertyComp\"\n" +
" m:metadata-etag=\"metadataETag\">\n" + " m:metadata-etag=\"metadataETag\">\n" +
" <m:element>\n" + " <m:element>\n" +
" <d:PropertyInt16 m:type=\"Int16\">123</d:PropertyInt16>\n" + " <d:PropertyInt16 m:type=\"Int16\">123</d:PropertyInt16>\n" +
" <d:PropertyString>TEST 1</d:PropertyString>\n" + " <d:PropertyString>TEST 1</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=entry\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
" </m:element>\n" + " </m:element>\n" +
" <m:element>\n" + " <m:element>\n" +
" <d:PropertyInt16 m:type=\"Int16\">456</d:PropertyInt16>\n" + " <d:PropertyInt16 m:type=\"Int16\">456</d:PropertyInt16>\n" +
" <d:PropertyString>TEST 2</d:PropertyString>\n" + " <d:PropertyString>TEST 2</d:PropertyString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=entry\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
" </m:element>\n" + " </m:element>\n" +
" <m:element m:type=\"olingo.odata.test1.CTBase\">\n" + " <m:element m:type=\"olingo.odata.test1.CTBase\">\n" +
" <d:PropertyInt16 m:type=\"Int16\">789</d:PropertyInt16>\n" + " <d:PropertyInt16 m:type=\"Int16\">789</d:PropertyInt16>\n" +
" <d:PropertyString>TEST 3</d:PropertyString>\n" + " <d:PropertyString>TEST 3</d:PropertyString>\n" +
" <d:AdditionalPropString>ADD TEST</d:AdditionalPropString>\n" + " <d:AdditionalPropString>ADD TEST</d:AdditionalPropString>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoKeyNavOne\" "
+ "type=\"application/atom+xml;type=entry\" title=\"NavPropertyETTwoKeyNavOne\" "
+ "href=\"ESTwoKeyNav(PropertyInt16=1,PropertyString='2')\"/>\n" +
"<a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETMediaOne\" "
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETMediaOne\" "
+ "href=\"CollPropertyComp/NavPropertyETMediaOne\"/>\n" +
" </m:element>\n" + " </m:element>\n" +
"</m:value>"; "</m:value>";
checkXMLEqual(expected, resultString); checkXMLEqual(expected, resultString);
@ -3210,7 +3318,7 @@ public class ODataXmlSerializerTest {
.build()).getContent()); .build()).getContent());
final String expectedResult = "<?xml version='1.0' encoding='UTF-8'?>" final String expectedResult = "<?xml version='1.0' encoding='UTF-8'?>"
+ "<m:value xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\" " + "<m:value xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\" "
+ "xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" " + "xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" xmlns:a=\"http://www.w3.org/2005/Atom\" "
+ "m:type=\"#Collection(olingo.odata.test1.CTPrimComp)\" " + "m:type=\"#Collection(olingo.odata.test1.CTPrimComp)\" "
+ "m:context=\"$metadata#ESKeyNav(1)/CollPropertyComp\" " + "m:context=\"$metadata#ESKeyNav(1)/CollPropertyComp\" "
+ "m:metadata-etag=\"metadataETag\">" + "m:metadata-etag=\"metadataETag\">"