[OLINGO-1246] Including key properties in context url and response payload even if select clause does not include key properties

This commit is contained in:
ramya vasanth 2018-03-21 09:52:07 +05:30
parent eea324d5a6
commit d9aff6300f
12 changed files with 125 additions and 65 deletions

View File

@ -90,7 +90,7 @@ public class ExpandSelectITCase extends AbstractParamTecSvcITCase {
final ClientEntity entity = response.getBody();
assertNotNull(entity);
assertNull(entity.getProperty("PropertyInt16"));
assertNotNull(entity.getProperty("PropertyInt16"));
final ClientProperty property = entity.getProperty("PropertyString");
assertNotNull(property);
@ -114,7 +114,7 @@ public class ExpandSelectITCase extends AbstractParamTecSvcITCase {
assertNotNull(entities);
assertEquals(2, entities.size());
final ClientEntity inlineEntity = entities.get(0);
assertEquals(2, inlineEntity.getProperties().size());
assertEquals(3, inlineEntity.getProperties().size());
assertShortOrInt(-128, inlineEntity.getProperty("PropertySByte").getPrimitiveValue().toValue());
Calendar time = Calendar.getInstance();
time.clear();

View File

@ -357,7 +357,7 @@ public class TripPinServiceTest {
public void testSelectOption() throws Exception {
HttpResponse response = httpGET(baseURL + "/People('russellwhyte')?$select=FirstName,LastName", 200);
JsonNode node = getJSONNode(response);
assertEquals("$metadata#People(FirstName,LastName)/$entity", node.get("@odata.context").asText());
assertEquals("$metadata#People(UserName,FirstName,LastName)/$entity", node.get("@odata.context").asText());
assertEquals("Russell", node.get("FirstName").asText());
}
@ -432,13 +432,13 @@ public class TripPinServiceTest {
HttpResponse response = httpGET(baseURL+"/$entity?$id="+baseURL
+ "/People('kristakemp')&$select=FirstName", 200);
JsonNode node = getJSONNode(response);
assertEquals("$metadata#People(FirstName)/$entity", node.get("@odata.context").asText());
assertEquals("$metadata#People(UserName,FirstName)/$entity", node.get("@odata.context").asText());
assertEquals("Krista", node.get("FirstName").asText());
// using relative URL
response = httpGET(baseURL+"/$entity?$id="+"People('kristakemp')&$select=FirstName", 200);
node = getJSONNode(response);
assertEquals("$metadata#People(FirstName)/$entity", node.get("@odata.context").asText());
assertEquals("$metadata#People(UserName,FirstName)/$entity", node.get("@odata.context").asText());
assertEquals("Krista", node.get("FirstName").asText());
}

View File

@ -530,6 +530,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
final boolean all = ExpandSelectHelper.isAll(select);
final Set<String> selected = all ? new HashSet<String>() :
ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
addKeyPropertiesToSelected(selected, type);
for (final String propertyName : type.getPropertyNames()) {
if (all || selected.contains(propertyName)) {
final EdmProperty edmProperty = type.getStructuralProperty(propertyName);
@ -540,6 +541,17 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
}
}
}
private void addKeyPropertiesToSelected(Set<String> selected, EdmStructuredType type) {
if (!selected.isEmpty() && type instanceof EdmEntityType) {
List<String> keyNames = ((EdmEntityType) type).getKeyPredicateNames();
for (String key : keyNames) {
if (!selected.contains(key)) {
selected.add(key);
}
}
}
}
protected void writeNavigationProperties(final ServiceMetadata metadata,
final EdmStructuredType type, final Linked linked, final ExpandOption expand, final Integer toDepth,

View File

@ -27,6 +27,7 @@ import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.EdmComplexType;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.commons.api.edm.EdmProperty;
import org.apache.olingo.commons.api.edm.EdmStructuredType;
@ -85,10 +86,7 @@ public final class ContextURLHelper {
for (final String propertyName : type.getNavigationPropertyNames()) {
constructSelectItemList(type, result, selectItems, selectedPropertyNames, propertyName);
}
if ((result.toString().length() == 0 && !selectItems.isEmpty()) ||
(result.toString().split(",").length < selectItems.size())) {
constructSelectItemListForActionsAndFunctions(type, result, selectItems);
}
constructSelectItemListForActionsAndFunctions(type, result, selectItems);
}
}
@ -202,6 +200,16 @@ public final class ContextURLHelper {
}
}
}
} else {
if (type instanceof EdmEntityType) {
final List<String> keyNames = ((EdmEntityType) type).getKeyPredicateNames();
if (keyNames.contains(propertyName)) {
if (result.length() > 0) {
result.append(',');
}
result.append(Encoder.encode(propertyName));
}
}
}
}

View File

@ -630,6 +630,7 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
final boolean all = ExpandSelectHelper.isAll(select);
final Set<String> selected = all ? new HashSet<String>() :
ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
addKeyPropertiesToSelected(selected, type);
for (final String propertyName : type.getPropertyNames()) {
if (all || selected.contains(propertyName)) {
final EdmProperty edmProperty = type.getStructuralProperty(propertyName);
@ -641,6 +642,17 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
}
}
private void addKeyPropertiesToSelected(Set<String> selected, EdmStructuredType type) {
if (!selected.isEmpty() && type instanceof EdmEntityType) {
List<String> keyNames = ((EdmEntityType) type).getKeyPredicateNames();
for (String key : keyNames) {
if (!selected.contains(key)) {
selected.add(key);
}
}
}
}
protected void writeNavigationProperties(final ServiceMetadata metadata,
final EdmStructuredType type, final Linked linked, final ExpandOption expand, final Integer toDepth,
final String xml10InvalidCharReplacement, final Set<String> ancestors, String name, final XMLStreamWriter writer)

View File

@ -892,7 +892,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
throws ODataLibraryException {
ContextURL contextUrl = isODataMetadataNone(requestedFormat) ? null :
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, true, expand, null,isContNav);
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, true, expand, select,isContNav);
return odata.createSerializer(requestedFormat, request.getHeaders(HttpHeader.ODATA_VERSION)).entity(
serviceMetadata,
edmEntityType,

View File

@ -453,7 +453,7 @@ public class JsonDeltaSerializerTest {
.select(select).build()).getContent();
String jsonString = IOUtils.toString(stream);
Assert.assertEquals("{"
+"\"@odata.context\":\"$metadata#ESDelta(PropertyString)/$entity/$delta\","
+"\"@odata.context\":\"$metadata#ESDelta(PropertyInt16,PropertyString)/$entity/$delta\","
+ "\"value\":[{\"@odata.id\":\"ESDelta(32767)\",\"PropertyString\":\"Number:32767\"},"
+ "{\"@odata.id\":\"ESDelta(-32768)\",\"PropertyString\":\"Number:-32768\"}]}",
jsonString);

View File

@ -608,7 +608,8 @@ public class JsonDeltaSerializerWithNavigationsTest {
.build()).getContent();
String jsonString = IOUtils.toString(stream);
Assert.assertEquals("{"
+ "\"@context\":\"$metadata#ESDelta(PropertyString,NavPropertyETAllPrimOne(PropertyString))/$delta\","
+ "\"@context\":\"$metadata#ESDelta(PropertyInt16,PropertyString,NavPropertyETAllPrimOne("
+ "PropertyInt16,PropertyString))/$delta\","
+ "\"value\":[{\"@id\":\"ESDelta(100)\",\"PropertyInt16\":100,\"PropertyString\":\"Number:100\","
+ "\"NavPropertyETAllPrimOne@delta\":{\"@id\":\"ESAllPrim(32767)\","
+ "\"PropertyString\":\"First Resource - positive values\"}}]}",
@ -642,7 +643,7 @@ public class JsonDeltaSerializerWithNavigationsTest {
.select(select).build()).getContent();
String jsonString = IOUtils.toString(stream);
Assert.assertEquals("{"
+"\"@context\":\"$metadata#ESDelta(PropertyString)/$entity/$delta\","
+"\"@context\":\"$metadata#ESDelta(PropertyInt16,PropertyString)/$entity/$delta\","
+ "\"value\":[{\"@id\":\"ESDelta(32767)\",\"PropertyString\":\"Number:32767\"},"
+ "{\"@id\":\"ESDelta(-32768)\",\"PropertyString\":\"Number:-32768\"}]}",
jsonString);

View File

@ -1162,9 +1162,9 @@ public class ODataJsonSerializerTest {
.build()).getContent();
final String resultString = IOUtils.toString(result);
final String expectedResult = "{"
+ "\"@odata.context\":\"$metadata#ESAllPrim(PropertyBoolean,PropertyDate)/$entity\","
+ "\"@odata.context\":\"$metadata#ESAllPrim(PropertyInt16,PropertyBoolean,PropertyDate)/$entity\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@odata.id\":\"ESAllPrim(32767)\","
+ "\"@odata.id\":\"ESAllPrim(32767)\",\"PropertyInt16\":32767,"
+ "\"PropertyBoolean\":true,\"PropertyDate\":\"2012-12-03\"}";
Assert.assertEquals(expectedResult, resultString);
}
@ -1275,11 +1275,11 @@ public class ODataJsonSerializerTest {
String expected = "{"
+ "\"@odata.context\":\"$metadata#ESFourKeyAlias"
+ "(PropertyComp/PropertyString,PropertyCompComp/PropertyComp)\","
+ "(PropertyInt16,PropertyComp/PropertyString,PropertyCompComp/PropertyComp)\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"value\":[{"
+ "\"@odata.id\":\"ESFourKeyAlias(PropertyInt16=1,KeyAlias1=11,KeyAlias2='Num11',KeyAlias3='Num111')\","
+ "\"PropertyComp\":{"
+ "\"PropertyInt16\":1,\"PropertyComp\":{"
+ "\"PropertyString\":\"Num11\""
+ "},"
+ "\"PropertyCompComp\":{"
@ -1433,9 +1433,10 @@ public class ODataJsonSerializerTest {
.build()).getContent();
Assert.assertNotNull(result);
final String resultString = IOUtils.toString(result);
Assert.assertEquals( "{\"@odata.context\":\"$metadata#ESAllPrim(PropertyBoolean,PropertyDate)/$entity\","+
Assert.assertEquals( "{\"@odata.context\":\"$metadata#ESAllPrim(PropertyInt16,"
+ "PropertyBoolean,PropertyDate)/$entity\","+
"\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\",\"@odata.id\":\"ESAllPrim(32767)\","+
"\"PropertyBoolean\":true,\"PropertyDate\":\"2012-12-03\"}",
"\"PropertyInt16\":32767,\"PropertyBoolean\":true,\"PropertyDate\":\"2012-12-03\"}",
resultString);
}
@ -1493,10 +1494,12 @@ public class ODataJsonSerializerTest {
.expand(expand)
.build()).getContent());
Assert.assertEquals("{"
+ "\"@odata.context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimOne(PropertyDate))/$entity\","
+ "\"@odata.context\":\"$metadata#ESTwoPrim(PropertyInt16,"
+ "NavPropertyETAllPrimOne(PropertyInt16,PropertyDate))/$entity\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\","
+ "\"NavPropertyETAllPrimOne\":{\"@odata.id\":\"ESAllPrim(32767)\",\"PropertyDate\":\"2012-12-03\"}}",
+ "\"NavPropertyETAllPrimOne\":{\"@odata.id\":\"ESAllPrim(32767)\","
+ "\"PropertyInt16\":32767,\"PropertyDate\":\"2012-12-03\"}}",
resultString);
}
@ -1522,9 +1525,9 @@ public class ODataJsonSerializerTest {
.select(select)
.build()).getContent());
Assert.assertEquals("{"
+ "\"@odata.context\":\"$metadata#ESAllPrim(PropertySByte)/$entity\","
+ "\"@odata.context\":\"$metadata#ESAllPrim(PropertyInt16,PropertySByte)/$entity\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@odata.id\":\"ESAllPrim(32767)\","
+ "\"@odata.id\":\"ESAllPrim(32767)\",\"PropertyInt16\":32767,"
+ "\"PropertySByte\":127,"
+ "\"NavPropertyETTwoPrimOne\":{\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"},"
+ "\"NavPropertyETTwoPrimMany\":[{\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\"}]}",
@ -1551,9 +1554,9 @@ public class ODataJsonSerializerTest {
.select(select)
.build()).getContent());
Assert.assertEquals("{"
+ "\"@odata.context\":\"$metadata#ESAllPrim(PropertyTimeOfDay)/$entity\","
+ "\"@odata.context\":\"$metadata#ESAllPrim(PropertyInt16,PropertyTimeOfDay)/$entity\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@odata.id\":\"ESAllPrim(-32768)\","
+ "\"@odata.id\":\"ESAllPrim(-32768)\",\"PropertyInt16\":-32768,"
+ "\"PropertyTimeOfDay\":\"23:49:14\","
+ "\"NavPropertyETTwoPrimOne\":null,\"NavPropertyETTwoPrimMany\":[]}",
resultString);
@ -1583,13 +1586,14 @@ public class ODataJsonSerializerTest {
.expand(expand)
.build()).getContent());
Assert.assertEquals("{"
+ "\"@odata.context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimMany(PropertyInt32))/$entity\","
+ "\"@odata.context\":\"$metadata#ESTwoPrim(PropertyInt16,"
+ "NavPropertyETAllPrimMany(PropertyInt16,PropertyInt32))/$entity\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\","
+ "\"NavPropertyETAllPrimMany\":["
+ "{\"@odata.id\":\"ESAllPrim(-32768)\",\"PropertyInt32\":-2147483648,"
+ "{\"@odata.id\":\"ESAllPrim(-32768)\",\"PropertyInt16\":-32768,\"PropertyInt32\":-2147483648,"
+ "\"NavPropertyETTwoPrimOne\":null,\"NavPropertyETTwoPrimMany\":[]},"
+ "{\"@odata.id\":\"ESAllPrim(0)\",\"PropertyInt32\":0,\"NavPropertyETTwoPrimOne\":{"
+ "{\"@odata.id\":\"ESAllPrim(0)\",\"PropertyInt16\":0,\"PropertyInt32\":0,\"NavPropertyETTwoPrimOne\":{"
+ "\"@odata.type\":\"#olingo.odata.test1.ETBase\",\"PropertyInt16\":111,"
+ "\"PropertyString\":\"TEST A\",\"AdditionalPropertyString_5\":\"TEST A 0815\"},"
+ "\"NavPropertyETTwoPrimMany\":["
@ -1621,7 +1625,7 @@ public class ODataJsonSerializerTest {
.suffix(Suffix.ENTITY).build())
.expand(expand)
.build()).getContent());
Assert.assertEquals("{\"@odata.context\":\"$metadata#ESTwoPrim/$entity\","
Assert.assertEquals("{\"@odata.context\":\"$metadata#ESTwoPrim(PropertyInt16)/$entity\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\","
+ "\"NavPropertyETAllPrimOne\":null,"
@ -2693,7 +2697,7 @@ public class ODataJsonSerializerTest {
final String expectedResult = "{\"@odata.context\":\"$metadata#ESTwoKeyNav/$entity\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@odata.id\":\"ESTwoKeyNav(PropertyInt16=1,PropertyString='1')\","
+ "\"CollPropertyCompNav\":[{}]}";
+ "\"PropertyInt16\":1,\"PropertyString\":\"1\",\"CollPropertyCompNav\":[{}]}";
Assert.assertEquals(expectedResult, resultString);
}
}

View File

@ -1175,9 +1175,9 @@ public class ODataJsonSerializerv01Test {
.build()).getContent();
final String resultString = IOUtils.toString(result);
final String expectedResult = "{"
+ "\"@context\":\"$metadata#ESAllPrim(PropertyBoolean,PropertyDate)/$entity\","
+ "\"@context\":\"$metadata#ESAllPrim(PropertyInt16,PropertyBoolean,PropertyDate)/$entity\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@id\":\"ESAllPrim(32767)\","
+ "\"@id\":\"ESAllPrim(32767)\",\"PropertyInt16\":32767,"
+ "\"PropertyBoolean\":true,\"PropertyDate\":\"2012-12-03\"}";
Assert.assertEquals(expectedResult, resultString);
}
@ -1288,11 +1288,11 @@ public class ODataJsonSerializerv01Test {
String expected = "{"
+ "\"@context\":\"$metadata#ESFourKeyAlias"
+ "(PropertyComp/PropertyString,PropertyCompComp/PropertyComp)\","
+ "(PropertyInt16,PropertyComp/PropertyString,PropertyCompComp/PropertyComp)\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"value\":[{"
+ "\"@id\":\"ESFourKeyAlias(PropertyInt16=1,KeyAlias1=11,KeyAlias2='Num11',KeyAlias3='Num111')\","
+ "\"PropertyComp\":{"
+ "\"PropertyInt16\":1,\"PropertyComp\":{"
+ "\"PropertyString\":\"Num11\""
+ "},"
+ "\"PropertyCompComp\":{"
@ -1446,9 +1446,10 @@ public class ODataJsonSerializerv01Test {
.build()).getContent();
Assert.assertNotNull(result);
final String resultString = IOUtils.toString(result);
Assert.assertEquals( "{\"@context\":\"$metadata#ESAllPrim(PropertyBoolean,PropertyDate)/$entity\","+
Assert.assertEquals( "{\"@context\":\"$metadata#ESAllPrim(PropertyInt16,"
+ "PropertyBoolean,PropertyDate)/$entity\","+
"\"@metadataEtag\":\"W/\\\"metadataETag\\\"\",\"@id\":\"ESAllPrim(32767)\","+
"\"PropertyBoolean\":true,\"PropertyDate\":\"2012-12-03\"}",
"\"PropertyInt16\":32767,\"PropertyBoolean\":true,\"PropertyDate\":\"2012-12-03\"}",
resultString);
}
@ -1506,10 +1507,12 @@ public class ODataJsonSerializerv01Test {
.expand(expand)
.build()).getContent());
Assert.assertEquals("{"
+ "\"@context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimOne(PropertyDate))/$entity\","
+ "\"@context\":\"$metadata#ESTwoPrim(PropertyInt16,"
+ "NavPropertyETAllPrimOne(PropertyInt16,PropertyDate))/$entity\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\","
+ "\"NavPropertyETAllPrimOne\":{\"@id\":\"ESAllPrim(32767)\",\"PropertyDate\":\"2012-12-03\"}}",
+ "\"NavPropertyETAllPrimOne\":{\"@id\":\"ESAllPrim(32767)\","
+ "\"PropertyInt16\":32767,\"PropertyDate\":\"2012-12-03\"}}",
resultString);
}
@ -1535,9 +1538,9 @@ public class ODataJsonSerializerv01Test {
.select(select)
.build()).getContent());
Assert.assertEquals("{"
+ "\"@context\":\"$metadata#ESAllPrim(PropertySByte)/$entity\","
+ "\"@context\":\"$metadata#ESAllPrim(PropertyInt16,PropertySByte)/$entity\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@id\":\"ESAllPrim(32767)\","
+ "\"@id\":\"ESAllPrim(32767)\",\"PropertyInt16\":32767,"
+ "\"PropertySByte\":127,"
+ "\"NavPropertyETTwoPrimOne\":{\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\"},"
+ "\"NavPropertyETTwoPrimMany\":[{\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\"}]}",
@ -1564,9 +1567,9 @@ public class ODataJsonSerializerv01Test {
.select(select)
.build()).getContent());
Assert.assertEquals("{"
+ "\"@context\":\"$metadata#ESAllPrim(PropertyTimeOfDay)/$entity\","
+ "\"@context\":\"$metadata#ESAllPrim(PropertyInt16,PropertyTimeOfDay)/$entity\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"@id\":\"ESAllPrim(-32768)\","
+ "\"@id\":\"ESAllPrim(-32768)\",\"PropertyInt16\":-32768,"
+ "\"PropertyTimeOfDay\":\"23:49:14\","
+ "\"NavPropertyETTwoPrimOne\":null,\"NavPropertyETTwoPrimMany\":[]}",
resultString);
@ -1596,13 +1599,14 @@ public class ODataJsonSerializerv01Test {
.expand(expand)
.build()).getContent());
Assert.assertEquals("{"
+ "\"@context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimMany(PropertyInt32))/$entity\","
+ "\"@context\":\"$metadata#ESTwoPrim(PropertyInt16,"
+ "NavPropertyETAllPrimMany(PropertyInt16,PropertyInt32))/$entity\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\","
+ "\"NavPropertyETAllPrimMany\":["
+ "{\"@id\":\"ESAllPrim(-32768)\",\"PropertyInt32\":-2147483648,"
+ "{\"@id\":\"ESAllPrim(-32768)\",\"PropertyInt16\":-32768,\"PropertyInt32\":-2147483648,"
+ "\"NavPropertyETTwoPrimOne\":null,\"NavPropertyETTwoPrimMany\":[]},"
+ "{\"@id\":\"ESAllPrim(0)\",\"PropertyInt32\":0,\"NavPropertyETTwoPrimOne\":{"
+ "{\"@id\":\"ESAllPrim(0)\",\"PropertyInt16\":0,\"PropertyInt32\":0,\"NavPropertyETTwoPrimOne\":{"
+ "\"@type\":\"#olingo.odata.test1.ETBase\",\"PropertyInt16\":111,"
+ "\"PropertyString\":\"TEST A\",\"AdditionalPropertyString_5\":\"TEST A 0815\"},"
+ "\"NavPropertyETTwoPrimMany\":["
@ -1634,7 +1638,7 @@ public class ODataJsonSerializerv01Test {
.suffix(Suffix.ENTITY).build())
.expand(expand)
.build()).getContent());
Assert.assertEquals("{\"@context\":\"$metadata#ESTwoPrim/$entity\","
Assert.assertEquals("{\"@context\":\"$metadata#ESTwoPrim(PropertyInt16)/$entity\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"PropertyInt16\":-365,\"PropertyString\":\"Test String2\","
+ "\"NavPropertyETAllPrimOne\":null,"

View File

@ -223,8 +223,8 @@ public class ContextURLHelperTest {
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, select)).build();
assertEquals("$metadata#ESTwoPrim(PropertyString,NavPropertyETAllPrimOne(),"
+ "NavPropertyETAllPrimMany(PropertyInt32))",
assertEquals("$metadata#ESTwoPrim(PropertyInt16,PropertyString,NavPropertyETAllPrimOne(),"
+ "NavPropertyETAllPrimMany(PropertyInt16,PropertyInt32))",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -342,7 +342,8 @@ public class ContextURLHelperTest {
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
assertEquals("$metadata#ESCompCollDerived(PropertyCompAno/olingo.odata.test1.CTBaseAno/AdditionalPropString)",
assertEquals("$metadata#ESCompCollDerived(PropertyInt16,PropertyCompAno/"
+ "olingo.odata.test1.CTBaseAno/AdditionalPropString)",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -356,7 +357,7 @@ public class ContextURLHelperTest {
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
assertEquals("$metadata#ESCompCollComp(PropertyComp/CollPropertyComp/"
assertEquals("$metadata#ESCompCollComp(PropertyInt16,PropertyComp/CollPropertyComp/"
+ "olingo.odata.test1.CTBase/AdditionalPropString)",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -372,7 +373,9 @@ public class ContextURLHelperTest {
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
assertEquals("$metadata#ESTwoKeyNav(olingo.odata.test1.ETBaseTwoKeyNav/NavPropertyETBaseTwoKeyNavOne)",
assertEquals("$metadata#ESTwoKeyNav(PropertyInt16,PropertyString,"
+ "olingo.odata.test1.ETBaseTwoKeyNav/"
+ "NavPropertyETBaseTwoKeyNavOne)",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -387,7 +390,8 @@ public class ContextURLHelperTest {
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
assertEquals("$metadata#ESTwoKeyNav(olingo.odata.test1.ETBaseTwoKeyNav/PropertyDate)",
assertEquals("$metadata#ESTwoKeyNav(PropertyInt16,PropertyString,"
+ "olingo.odata.test1.ETBaseTwoKeyNav/PropertyDate)",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -403,7 +407,8 @@ public class ContextURLHelperTest {
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem1, selectItem2));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
assertEquals("$metadata#ESTwoKeyNav(CollPropertyComp,olingo.odata.test1.ETBaseTwoKeyNav/"
assertEquals("$metadata#ESTwoKeyNav(PropertyInt16,PropertyString,"
+ "CollPropertyComp,olingo.odata.test1.ETBaseTwoKeyNav/"
+ "NavPropertyETTwoBaseTwoKeyNavOne)",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -421,7 +426,8 @@ public class ContextURLHelperTest {
final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
assertEquals("$metadata#ESTwoKeyNav(olingo.odata.test1.ETBaseTwoKeyNav/CollPropertyComp/"
assertEquals("$metadata#ESTwoKeyNav(PropertyInt16,PropertyString,"
+ "olingo.odata.test1.ETBaseTwoKeyNav/CollPropertyComp/"
+ "olingo.odata.test1.CTBasePrimCompNav/NavPropertyETTwoKeyNavOne)",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -443,7 +449,7 @@ public class ContextURLHelperTest {
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), expand, null)).build();
assertEquals("$metadata#ESKeyNavCont(NavPropertyETTwoKeyNavContOne("
+ "olingo.odata.test1.ETBaseTwoKeyNav/PropertyDate))",
+ "PropertyInt16,PropertyString,olingo.odata.test1.ETBaseTwoKeyNav/PropertyDate))",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -456,7 +462,8 @@ public class ContextURLHelperTest {
selectItem));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
assertEquals("$metadata#ESTwoKeyNav(CollPropertyCompNav/NavPropertyETTwoKeyNavMany)",
assertEquals("$metadata#ESTwoKeyNav(PropertyInt16,PropertyString,"
+ "CollPropertyCompNav/NavPropertyETTwoKeyNavMany)",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -472,7 +479,8 @@ public class ContextURLHelperTest {
selectItem));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
assertEquals("$metadata#ESTwoKeyNav(olingo.odata.test1.BAESTwoKeyNavRTESTwoKeyNav)",
assertEquals("$metadata#ESTwoKeyNav(PropertyInt16,PropertyString,"
+ "olingo.odata.test1.BAESTwoKeyNavRTESTwoKeyNav)",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -490,7 +498,8 @@ public class ContextURLHelperTest {
selectItem1, selectItem2));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
assertEquals("$metadata#ESTwoKeyNav(PropertyString,olingo.odata.test1.BAESTwoKeyNavRTESTwoKeyNav)",
assertEquals("$metadata#ESTwoKeyNav(PropertyInt16,PropertyString,"
+ "olingo.odata.test1.BAESTwoKeyNavRTESTwoKeyNav)",
ContextURLBuilder.create(contextURL).toASCIIString());
}
@ -506,7 +515,8 @@ public class ContextURLHelperTest {
selectItem));
final ContextURL contextURL = ContextURL.with().entitySet(entitySet)
.selectList(ContextURLHelper.buildSelectList(entitySet.getEntityType(), null, select)).build();
assertEquals("$metadata#ESTwoKeyNav(olingo.odata.test1.BFCESTwoKeyNavRTString)",
assertEquals("$metadata#ESTwoKeyNav(PropertyInt16,PropertyString,"
+ "olingo.odata.test1.BFCESTwoKeyNavRTString)",
ContextURLBuilder.create(contextURL).toASCIIString());
}
}

View File

@ -1521,7 +1521,7 @@ public class ODataXmlSerializerTest {
"<a:entry xmlns:a=\"http://www.w3.org/2005/Atom\"\n" +
" xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
" xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" " +
" m:context=\"$metadata#ESAllPrim(PropertyBoolean,PropertyDate)/$entity\"\n" +
" m:context=\"$metadata#ESAllPrim(PropertyInt16,PropertyBoolean,PropertyDate)/$entity\"\n" +
" m:metadata-etag=\"metadataETag\">\n" +
" <a:id>ESAllPrim(32767)</a:id>\n" +
" <a:title />\n" +
@ -1543,6 +1543,7 @@ public class ODataXmlSerializerTest {
" term=\"#olingo.odata.test1.ETAllPrim\" />\n" +
" <a:content type=\"application/xml\">\n" +
" <m:properties>\n" +
" <d:PropertyInt16 m:type=\"Int16\">32767</d:PropertyInt16>" +
" <d:PropertyBoolean m:type=\"Boolean\">true</d:PropertyBoolean>\n" +
" <d:PropertyDate m:type=\"Date\">2012-12-03</d:PropertyDate>\n" +
" </m:properties>\n" +
@ -1685,7 +1686,7 @@ public class ODataXmlSerializerTest {
"xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
"xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" \n" +
"m:context=\"$metadata#ESFourKeyAlias" +
"(PropertyComp/PropertyString,PropertyCompComp/PropertyComp)\"\n" +
"(PropertyInt16,PropertyComp/PropertyString,PropertyCompComp/PropertyComp)\"\n" +
"m:metadata-etag=\"metadataETag\">\n" +
"<a:id>http://host/svc/ESFourKeyAlias</a:id>\n" +
"<a:entry>\n" +
@ -1702,6 +1703,7 @@ public class ODataXmlSerializerTest {
"term=\"#olingo.odata.test1.ETFourKeyAlias\"/>\n" +
"<a:content type=\"application/xml\">\n" +
"<m:properties>\n" +
" <d:PropertyInt16 m:type=\"Int16\">1</d:PropertyInt16>" +
"<d:PropertyComp m:type=\"#olingo.odata.test1.CTTwoPrim\">\n" +
"<d:PropertyString>Num11</d:PropertyString>\n" +
"</d:PropertyComp>\n" +
@ -1951,7 +1953,8 @@ public class ODataXmlSerializerTest {
"<a:entry xmlns:a=\"http://www.w3.org/2005/Atom\" "
+ "xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
" xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\"\n" +
" m:context=\"$metadata#ESTwoPrim(NavPropertyETAllPrimOne(PropertyDate))/$entity\"\n" +
" m:context=\"$metadata#ESTwoPrim(PropertyInt16,"
+ "NavPropertyETAllPrimOne(PropertyInt16,PropertyDate))/$entity\"\n" +
" m:metadata-etag=\"metadataETag\">\n" +
" <a:id>ESTwoPrim(32767)</a:id>\n" +
" <a:title />\n" +
@ -1987,6 +1990,7 @@ public class ODataXmlSerializerTest {
" term=\"#olingo.odata.test1.ETAllPrim\" />\n" +
" <a:content type=\"application/xml\">\n" +
" <m:properties>\n" +
" <d:PropertyInt16 m:type=\"Int16\">32767</d:PropertyInt16>" +
" <d:PropertyDate m:type=\"Date\">2012-12-03</d:PropertyDate>\n" +
" </m:properties>\n" +
" </a:content>\n" +
@ -2051,7 +2055,7 @@ public class ODataXmlSerializerTest {
"<a:entry xmlns:a=\"http://www.w3.org/2005/Atom\"\n" +
" xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
" xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" "
+ "m:context=\"$metadata#ESAllPrim(PropertySByte)/$entity\"\n" +
+ "m:context=\"$metadata#ESAllPrim(PropertyInt16,PropertySByte)/$entity\"\n" +
" m:metadata-etag=\"metadataETag\">\n" +
" <a:id>ESAllPrim(32767)</a:id>\n" +
" <a:title />\n" +
@ -2159,6 +2163,7 @@ public class ODataXmlSerializerTest {
" term=\"#olingo.odata.test1.ETAllPrim\" />\n" +
" <a:content type=\"application/xml\">\n" +
" <m:properties>\n" +
" <d:PropertyInt16 m:type=\"Int16\">32767</d:PropertyInt16>" +
" <d:PropertySByte m:type=\"SByte\">127</d:PropertySByte>\n" +
" </m:properties>\n" +
" </a:content>\n" +
@ -2195,7 +2200,7 @@ public class ODataXmlSerializerTest {
"<a:entry xmlns:a=\"http://www.w3.org/2005/Atom\" "
+ "xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
" xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\" "
+ "m:context=\"$metadata#ESAllPrim(PropertyTimeOfDay)/$entity\"\n" +
+ "m:context=\"$metadata#ESAllPrim(PropertyInt16,PropertyTimeOfDay)/$entity\"\n" +
" m:metadata-etag=\"metadataETag\">\n" +
" <a:id>ESAllPrim(-32768)</a:id>\n" +
" <a:title />\n" +
@ -2223,6 +2228,7 @@ public class ODataXmlSerializerTest {
" term=\"#olingo.odata.test1.ETAllPrim\" />\n" +
" <a:content type=\"application/xml\">\n" +
" <m:properties>\n" +
" <d:PropertyInt16 m:type=\"Int16\">-32768</d:PropertyInt16>" +
" <d:PropertyTimeOfDay m:type=\"TimeOfDay\">23:49:14\n" +
" </d:PropertyTimeOfDay>\n" +
" </m:properties>\n" +
@ -2263,7 +2269,8 @@ public class ODataXmlSerializerTest {
"<a:entry xmlns:a=\"http://www.w3.org/2005/Atom\" "
+ "xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
" xmlns:d=\"http://docs.oasis-open.org/odata/ns/data\"\n" +
" m:context=\"$metadata#ESTwoPrim(NavPropertyETAllPrimMany(PropertyInt32))/$entity\"\n" +
" m:context=\"$metadata#ESTwoPrim(PropertyInt16,"
+ "NavPropertyETAllPrimMany(PropertyInt16,PropertyInt32))/$entity\"\n" +
" m:metadata-etag=\"metadataETag\">\n" +
" <a:id>ESTwoPrim(-365)</a:id>\n" +
" <a:title />\n" +
@ -2311,6 +2318,7 @@ public class ODataXmlSerializerTest {
" term=\"#olingo.odata.test1.ETAllPrim\" />\n" +
" <a:content type=\"application/xml\">\n" +
" <m:properties>\n" +
" <d:PropertyInt16 m:type=\"Int16\">-32768</d:PropertyInt16>" +
" <d:PropertyInt32 m:type=\"Int32\">-2147483648</d:PropertyInt32>\n" +
" </m:properties>\n" +
" </a:content>\n" +
@ -2494,6 +2502,7 @@ public class ODataXmlSerializerTest {
" term=\"#olingo.odata.test1.ETAllPrim\" />\n" +
" <a:content type=\"application/xml\">\n" +
" <m:properties>\n" +
" <d:PropertyInt16 m:type=\"Int16\">0</d:PropertyInt16>" +
" <d:PropertyInt32 m:type=\"Int32\">0</d:PropertyInt32>\n" +
" </m:properties>\n" +
" </a:content>\n" +