Merge remote-tracking branch 'origin/OLINGO-640'
This commit is contained in:
commit
633578a180
|
@ -78,6 +78,7 @@ import org.apache.olingo.commons.api.http.HttpHeader;
|
|||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -100,6 +101,15 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
private static final String ES_TWO_PRIM = "ESTwoPrim";
|
||||
private static final String ES_KEY_NAV = "ESKeyNav";
|
||||
|
||||
|
||||
void assertShortOrInt(int value, Object n) {
|
||||
if (n instanceof Number) {
|
||||
assertEquals(value, ((Number)n).intValue());
|
||||
} else {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readServiceDocument() {
|
||||
ODataServiceDocumentRequest request = getClient().getRetrieveRequestFactory()
|
||||
|
@ -111,7 +121,6 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
ClientServiceDocument serviceDocument = response.getBody();
|
||||
assertNotNull(serviceDocument);
|
||||
|
||||
assertThat(serviceDocument.getEntitySetNames(), hasItem("ESAllPrim"));
|
||||
assertThat(serviceDocument.getFunctionImportNames(), hasItem("FICRTCollCTTwoPrim"));
|
||||
assertThat(serviceDocument.getSingletonNames(), hasItem("SIMedia"));
|
||||
|
@ -162,7 +171,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
assertThat(response.getContentType(), containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
|
||||
assertContentType(response.getContentType());
|
||||
|
||||
final ClientEntitySet entitySet = response.getBody();
|
||||
assertNotNull(entitySet);
|
||||
|
@ -180,9 +189,21 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
final ClientProperty property = entity.getProperty("PropertyInt16");
|
||||
assertNotNull(property);
|
||||
assertNotNull(property.getPrimitiveValue());
|
||||
assertEquals(0, property.getPrimitiveValue().toValue());
|
||||
if (isJson()) {
|
||||
assertEquals(0, property.getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals((short)0, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
|
||||
}
|
||||
|
||||
private boolean isJson() {
|
||||
return getClient().getConfiguration().getDefaultPubFormat().equals(ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readEntityCollectionCount() {
|
||||
final ODataValueRequest request = getClient().getRetrieveRequestFactory()
|
||||
|
@ -225,7 +246,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
final ODataRetrieveResponse<ClientEntity> response = request.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
assertThat(response.getContentType(), containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
|
||||
assertContentType(response.getContentType());
|
||||
|
||||
final ClientEntity entity = response.getBody();
|
||||
assertNotNull(entity);
|
||||
|
@ -234,9 +255,15 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
assertNotNull(property.getCollectionValue());
|
||||
assertEquals(3, property.getCollectionValue().size());
|
||||
Iterator<ClientValue> iterator = property.getCollectionValue().iterator();
|
||||
assertEquals(1000, iterator.next().asPrimitive().toValue());
|
||||
assertEquals(2000, iterator.next().asPrimitive().toValue());
|
||||
assertEquals(30112, iterator.next().asPrimitive().toValue());
|
||||
if(isJson()) {
|
||||
assertEquals(1000, iterator.next().asPrimitive().toValue());
|
||||
assertEquals(2000, iterator.next().asPrimitive().toValue());
|
||||
assertEquals(30112, iterator.next().asPrimitive().toValue());
|
||||
} else {
|
||||
assertEquals((short)1000, iterator.next().asPrimitive().toValue());
|
||||
assertEquals((short)2000, iterator.next().asPrimitive().toValue());
|
||||
assertEquals((short)30112, iterator.next().asPrimitive().toValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -268,7 +295,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
patchEntity.getProperties().add(factory.newPrimitiveProperty("PropertyString",
|
||||
factory.newPrimitiveValueBuilder().buildString("new")));
|
||||
patchEntity.getProperties().add(factory.newPrimitiveProperty("PropertyDecimal",
|
||||
factory.newPrimitiveValueBuilder().buildDouble(42.875)));
|
||||
factory.newPrimitiveValueBuilder().buildDecimal(new BigDecimal(42.875))));
|
||||
patchEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
|
||||
factory.newPrimitiveValueBuilder().buildInt64(null)));
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").appendKeySegment(32767)
|
||||
|
@ -286,13 +313,22 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
assertEquals("new", property1.getPrimitiveValue().toValue());
|
||||
final ClientProperty property2 = entity.getProperty("PropertyDecimal");
|
||||
assertNotNull(property2);
|
||||
assertEquals(42.875, property2.getPrimitiveValue().toValue());
|
||||
if (isJson()) {
|
||||
assertEquals(42.875, property2.getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals(new BigDecimal(42.875), property2.getPrimitiveValue().toValue());
|
||||
}
|
||||
final ClientProperty property3 = entity.getProperty("PropertyInt64");
|
||||
assertNotNull(property3);
|
||||
assertNull(property3.getPrimitiveValue());
|
||||
final ClientProperty property4 = entity.getProperty("PropertyDuration");
|
||||
assertNotNull(property4);
|
||||
assertEquals("PT6S", property4.getPrimitiveValue().toValue());
|
||||
if (isJson()) {
|
||||
assertEquals("PT6S", property4.getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals(new BigDecimal(6), property4.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -301,7 +337,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
final ClientObjectFactory factory = client.getObjectFactory();
|
||||
ClientEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
|
||||
newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
|
||||
factory.newPrimitiveValueBuilder().buildInt32(42)));
|
||||
factory.newPrimitiveValueBuilder().buildInt64((long)42)));
|
||||
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").appendKeySegment(32767)
|
||||
.build();
|
||||
|
@ -315,7 +351,11 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
assertNotNull(entity);
|
||||
final ClientProperty property1 = entity.getProperty("PropertyInt64");
|
||||
assertNotNull(property1);
|
||||
assertEquals(42, property1.getPrimitiveValue().toValue());
|
||||
if (isJson()) {
|
||||
assertEquals(42, property1.getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals((long)42, property1.getPrimitiveValue().toValue());
|
||||
}
|
||||
final ClientProperty property2 = entity.getProperty("PropertyDecimal");
|
||||
assertNotNull(property2);
|
||||
assertNull(property2.getPrimitiveValue());
|
||||
|
@ -331,7 +371,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
factory.newComplexProperty("PropertyComp",
|
||||
factory.newComplexValue("olingo.odata.test1.CTTwoPrim").add(
|
||||
factory.newPrimitiveProperty("PropertyInt16",
|
||||
factory.newPrimitiveValueBuilder().buildInt32(42)))))));
|
||||
factory.newPrimitiveValueBuilder().buildInt16((short)42)))))));
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESCompComp").appendKeySegment(1).build();
|
||||
final ODataEntityUpdateRequest<ClientEntity> request = client.getCUDRequestFactory().getEntityUpdateRequest(
|
||||
uri, UpdateType.PATCH, patchEntity);
|
||||
|
@ -346,7 +386,11 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
assertNotNull(complex);
|
||||
final ClientProperty property1 = complex.get("PropertyInt16");
|
||||
assertNotNull(property1);
|
||||
assertEquals(42, property1.getPrimitiveValue().toValue());
|
||||
if (isJson()) {
|
||||
assertEquals(42, property1.getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals((short)42, property1.getPrimitiveValue().toValue());
|
||||
}
|
||||
final ClientProperty property2 = complex.get("PropertyString");
|
||||
assertNotNull(property2);
|
||||
assertEquals("String 1", property2.getPrimitiveValue().toValue());
|
||||
|
@ -394,7 +438,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
final ClientObjectFactory factory = client.getObjectFactory();
|
||||
ClientEntity newEntity = factory.newEntity(new FullQualifiedName("olingo.odata.test1", "ETAllPrim"));
|
||||
newEntity.getProperties().add(factory.newPrimitiveProperty("PropertyInt64",
|
||||
factory.newPrimitiveValueBuilder().buildInt32(42)));
|
||||
factory.newPrimitiveValueBuilder().buildInt64((long)42)));
|
||||
newEntity.addLink(factory.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_PRIM_ONE,
|
||||
client.newURIBuilder(SERVICE_URI)
|
||||
.appendEntitySetSegment("ESTwoPrim")
|
||||
|
@ -413,7 +457,11 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
assertNotNull(createdEntity);
|
||||
final ClientProperty property1 = createdEntity.getProperty("PropertyInt64");
|
||||
assertNotNull(property1);
|
||||
assertEquals(42, property1.getPrimitiveValue().toValue());
|
||||
if(isJson()) {
|
||||
assertEquals(42, property1.getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals((long)42, property1.getPrimitiveValue().toValue());
|
||||
}
|
||||
final ClientProperty property2 = createdEntity.getProperty("PropertyDecimal");
|
||||
assertNotNull(property2);
|
||||
assertNull(property2.getPrimitiveValue());
|
||||
|
@ -441,7 +489,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void readEntityWithExpandedNavigationProperty() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI)
|
||||
|
@ -532,14 +580,22 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
.iterator();
|
||||
|
||||
ClientComplexValue complexProperty = collectionIterator.next().asComplex();
|
||||
assertEquals(42, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
if (isJson()) {
|
||||
assertEquals(42, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals((short)42, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
assertNotNull(complexProperty.get("PropertyComp"));
|
||||
|
||||
ClientComplexValue innerComplexProperty = complexProperty.get("PropertyComp").getComplexValue();
|
||||
assertEquals("42", innerComplexProperty.get("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
complexProperty = collectionIterator.next().asComplex();
|
||||
assertEquals(43, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
if (isJson()) {
|
||||
assertEquals(43, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals((short)43, complexProperty.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
assertNotNull(complexProperty.get("PropertyComp"));
|
||||
|
||||
innerComplexProperty = complexProperty.get("PropertyComp").getComplexValue();
|
||||
|
@ -601,7 +657,11 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(2, newEntity.getProperty("CollPropertyComp").getCollectionValue().size());
|
||||
final Iterator<ClientValue> iter = newEntity.getProperty("CollPropertyComp").getCollectionValue().iterator();
|
||||
final ClientComplexValue complexProperty1 = iter.next().asComplex();
|
||||
assertEquals(1, complexProperty1.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
if (isJson()) {
|
||||
assertEquals(1, complexProperty1.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals((short)1, complexProperty1.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
assertNotNull(complexProperty1.get("PropertyComp"));
|
||||
final ClientComplexValue innerComplexProperty1 = complexProperty1.get("PropertyComp").getComplexValue();
|
||||
assertEquals("1", innerComplexProperty1.get("PropertyString").getPrimitiveValue().toValue());
|
||||
|
@ -627,8 +687,14 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
assertNotNull(complexProperty2.get("PropertyComp"));
|
||||
final ClientComplexValue innerComplexProperty2 = complexProperty2.get("PropertyComp").getComplexValue();
|
||||
assertEquals("2", innerComplexProperty2.get("PropertyString").getPrimitiveValue().toValue());
|
||||
assertEquals(2, innerComplexProperty2.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals(Double.valueOf(2), innerComplexProperty2.get("PropertySingle").getPrimitiveValue().toValue());
|
||||
if(isJson()) {
|
||||
assertEquals(2, innerComplexProperty2.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals(Double.valueOf(2), innerComplexProperty2.get("PropertySingle").getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals((short)2, innerComplexProperty2.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals(Float.valueOf(2), innerComplexProperty2.get("PropertySingle").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
assertTrue(innerComplexProperty2.get("PropertyBinary").hasNullValue());
|
||||
assertTrue(innerComplexProperty2.get("PropertyBoolean").hasNullValue());
|
||||
assertTrue(innerComplexProperty2.get("PropertyByte").hasNullValue());
|
||||
|
@ -649,7 +715,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void complexPropertyWithNotNullablePrimitiveValue() {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
||||
// PropertyComp is null, but the primitive values in PropertyComp must not be null
|
||||
|
@ -666,7 +732,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void upsert() throws EdmPrimitiveTypeException {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
||||
final ClientEntity entity = of.newEntity(new FullQualifiedName("olingo.odata.test1", "ETTwoPrim"));
|
||||
|
@ -698,7 +764,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void updatePropertyWithNull() {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
||||
final URI targetURI = client.newURIBuilder(SERVICE_URI)
|
||||
|
@ -718,12 +784,12 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
assertEquals("return=representation", response.getHeader(HttpHeader.PREFERENCE_APPLIED).iterator().next());
|
||||
assertTrue(response.getBody().getProperty("PropertyString").hasNullValue());
|
||||
assertEquals(34, response.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(34, response.getBody().getProperty("PropertyDecimal").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test(expected = ODataClientErrorException.class)
|
||||
public void updatePropertyWithNullNotAllowed() {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
||||
final URI targetURI = client.newURIBuilder(SERVICE_URI)
|
||||
|
@ -740,9 +806,9 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void updateMerge() {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
||||
|
||||
final URI targetURI = client.newURIBuilder(SERVICE_URI)
|
||||
.appendEntitySetSegment("ESKeyNav")
|
||||
.appendKeySegment(1)
|
||||
|
@ -777,7 +843,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
|
||||
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), entityResponse.getStatusCode());
|
||||
assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
|
||||
assertShortOrInt(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
|
||||
.asInlineEntity()
|
||||
.getEntity()
|
||||
.getProperty("PropertyInt16")
|
||||
|
@ -790,7 +856,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
.getEntities()
|
||||
.size());
|
||||
|
||||
assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
assertShortOrInt(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
.asInlineEntitySet()
|
||||
.getEntitySet()
|
||||
.getEntities()
|
||||
|
@ -799,7 +865,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
.getPrimitiveValue()
|
||||
.toValue());
|
||||
|
||||
assertEquals(2, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
assertShortOrInt(2, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
.asInlineEntitySet()
|
||||
.getEntitySet()
|
||||
.getEntities()
|
||||
|
@ -808,7 +874,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
.getPrimitiveValue()
|
||||
.toValue());
|
||||
|
||||
assertEquals(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
assertShortOrInt(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
.asInlineEntitySet()
|
||||
.getEntitySet()
|
||||
.getEntities()
|
||||
|
@ -834,7 +900,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void updateReplace() {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
||||
final URI targetURI = client.newURIBuilder(SERVICE_URI)
|
||||
|
@ -877,7 +943,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
|
||||
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), entityResponse.getStatusCode());
|
||||
assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
|
||||
assertShortOrInt(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavOne")
|
||||
.asInlineEntity()
|
||||
.getEntity()
|
||||
.getProperty("PropertyInt16")
|
||||
|
@ -890,7 +956,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
.getEntities()
|
||||
.size());
|
||||
|
||||
assertEquals(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
assertShortOrInt(1, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
.asInlineEntitySet()
|
||||
.getEntitySet()
|
||||
.getEntities()
|
||||
|
@ -899,7 +965,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
.getPrimitiveValue()
|
||||
.toValue());
|
||||
|
||||
assertEquals(2, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
assertShortOrInt(2, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
.asInlineEntitySet()
|
||||
.getEntitySet()
|
||||
.getEntities()
|
||||
|
@ -908,7 +974,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
.getPrimitiveValue()
|
||||
.toValue());
|
||||
|
||||
assertEquals(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
assertShortOrInt(3, entityResponse.getBody().getNavigationLink("NavPropertyETKeyNavMany")
|
||||
.asInlineEntitySet()
|
||||
.getEntitySet()
|
||||
.getEntities()
|
||||
|
@ -938,7 +1004,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
.getComplexValue();
|
||||
|
||||
assertEquals("Must not be null", propCompTwoPrim.get("PropertyString").getPrimitiveValue().toValue());
|
||||
assertEquals(42, propCompTwoPrim.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(42, propCompTwoPrim.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
|
||||
assertNotNull(entityResponse.getBody().getProperty("PropertyCompNav").getComplexValue());
|
||||
assertTrue(entityResponse.getBody()
|
||||
|
@ -950,7 +1016,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void createEntityWithIEEE754CompatibleParameter() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).build();
|
||||
|
@ -977,7 +1043,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void createEntityWithIEEE754CompatibleParameterNull() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).build();
|
||||
|
@ -1003,7 +1069,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void updateEntityWithIEEE754CompatibleParameter() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).appendKeySegment(0).build();
|
||||
|
@ -1035,7 +1101,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void updateEntityWithIEEE754CompatibleParameterNull() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).appendKeySegment(0).build();
|
||||
|
@ -1065,7 +1131,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void updateEntityWithIEEE754CompatibleParameterWithNullString() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM).appendKeySegment(0).build();
|
||||
|
@ -1091,7 +1157,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void updateEdmInt64PropertyWithIEE754CompatibleParameter() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM)
|
||||
|
@ -1118,7 +1184,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void updateComplexPropertyWithIEEE754CompatibleParamter() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
|
||||
|
@ -1155,7 +1221,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void updateProperyEdmDecimaltWithIEE754CompatibleParameter() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM)
|
||||
|
@ -1182,7 +1248,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void readESAllPrimCollectionWithIEEE754CompatibleParameter() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_ALL_PRIM)
|
||||
.orderBy(PROPERTY_INT16)
|
||||
.build();
|
||||
|
@ -1213,7 +1279,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void readESKeyNavCheckComplexPropertyWithIEEE754CompatibleParameter() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).build();
|
||||
|
||||
final ODataEntityRequest<ClientEntity> request = client.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||
|
@ -1238,7 +1304,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void readESKEyNavComplexPropertyWithIEEE754CompatibleParameter() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
|
||||
.appendKeySegment(1)
|
||||
.appendNavigationSegment(PROPERTY_COMP_ALL_PRIM)
|
||||
|
@ -1262,7 +1328,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
@Test
|
||||
@Ignore
|
||||
public void readEdmInt64PropertyWithIEEE754ComaptibleParameter() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
|
||||
.appendKeySegment(1)
|
||||
.appendPropertySegment(PROPERTY_COMP_ALL_PRIM)
|
||||
|
@ -1279,7 +1345,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
@Test
|
||||
@Ignore
|
||||
public void readEdmDecimalPropertyWithIEEE754ComaptibleParameter() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
|
||||
.appendKeySegment(1)
|
||||
.appendPropertySegment(PROPERTY_COMP_ALL_PRIM)
|
||||
|
@ -1299,4 +1365,8 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.JSON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class BasicXmlITCase extends BasicITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -18,9 +18,11 @@
|
|||
*/
|
||||
package org.apache.olingo.fit.tecsvc.client;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -122,9 +124,13 @@ public class BatchClientITCase extends AbstractTestITCase {
|
|||
assertTrue(changeSetResponse.isBreaking());
|
||||
|
||||
assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), updateResponse.getStatusCode());
|
||||
assertEquals(ContentType.JSON.toContentTypeString(), updateResponse.getContentType());
|
||||
assertContentType(updateResponse.getContentType());
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyBatchRequest() {
|
||||
// create your request
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class BatchClientXmlITCase extends BatchClientITCase {
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -323,7 +323,7 @@ public class BindingITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void testDeepInsertWithBindingSameNavigationProperty() {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
||||
|
@ -395,4 +395,8 @@ public class BindingITCase extends AbstractBaseTestITCase {
|
|||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.JSON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@Ignore
|
||||
/**
|
||||
* I believe BindingITCase was not written correctly, as they seem to use navigation property and
|
||||
* any other property interchangeably. Once we fix that then we can remove the ignore
|
||||
*/
|
||||
public class BindingXmlITCase extends BindingITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -51,6 +51,7 @@ import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
|||
import org.apache.olingo.client.api.http.HttpClientException;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
|
@ -58,7 +59,7 @@ import org.apache.olingo.fit.AbstractBaseTestITCase;
|
|||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class ConditionalITCase extends AbstractBaseTestITCase {
|
||||
public class ConditionalITCase extends AbstractBaseTestITCase {
|
||||
|
||||
private final ODataClient client = getClient();
|
||||
|
||||
|
@ -123,14 +124,14 @@ public final class ConditionalITCase extends AbstractBaseTestITCase {
|
|||
public void updateWithoutIfMatch() throws Exception {
|
||||
executeAndExpectError(
|
||||
client.getCUDRequestFactory().getEntityUpdateRequest(
|
||||
uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(null)),
|
||||
uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(new FullQualifiedName("olingo.Order"))),
|
||||
HttpStatusCode.PRECONDITION_REQUIRED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateWithWrongIfMatch() throws Exception {
|
||||
ODataEntityUpdateRequest<ClientEntity> request = client.getCUDRequestFactory().getEntityUpdateRequest(
|
||||
uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(null));
|
||||
uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(new FullQualifiedName("olingo.Order")));
|
||||
request.setIfMatch("W/\"1\"");
|
||||
executeAndExpectError(request, HttpStatusCode.PRECONDITION_FAILED);
|
||||
}
|
||||
|
@ -173,7 +174,7 @@ public final class ConditionalITCase extends AbstractBaseTestITCase {
|
|||
final ODataDeleteResponse response = deleteRequest.execute();
|
||||
|
||||
ODataEntityUpdateRequest<ClientEntity> request = client.getCUDRequestFactory().getEntityUpdateRequest(
|
||||
uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(null));
|
||||
uriEntity, UpdateType.PATCH, client.getObjectFactory().newEntity(new FullQualifiedName("olingo.Order")));
|
||||
request.setIfMatch(eTag);
|
||||
// This request has to be in the same session as the first in order to access the same data provider.
|
||||
request.addCustomHeader(HttpHeader.COOKIE, response.getHeader(HttpHeader.SET_COOKIE).iterator().next());
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class ConditionalXmlITCase extends ConditionalITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -59,6 +59,19 @@ import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The issue I see with this unit test, or in general with JSON metadata=minimal case is
|
||||
* none of the navigation properties will be represented as such in deserialized form, because
|
||||
* no navigation link information will be written when metadata=minimal. The client will
|
||||
* interpret those results as complex properties (which I do not think is right).
|
||||
*
|
||||
* Where as in the atom+xml case, there is no intermediate results, it is equivalent to
|
||||
* metadata=full, thus the navigation links and inline content is correctly represented through
|
||||
* deserialization.
|
||||
*
|
||||
* For above reason, the DeepInsertXMLITCase case re-written slightly differently.
|
||||
*
|
||||
*/
|
||||
public class DeepInsertITCase extends AbstractBaseTestITCase {
|
||||
|
||||
private static final String SERVICE_URI = TecSvcConst.BASE_URI;
|
||||
|
@ -90,7 +103,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void testDeepInsertExpandedResponse() {
|
||||
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
@ -272,7 +285,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
inlineEntitySingle.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
|
||||
inlineEntitySingle.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 430)))));
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
|
||||
|
@ -293,7 +307,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
|
||||
inlineEntityCol1.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 440)))));
|
||||
inlineEntityCol1.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
|
||||
|
@ -308,7 +323,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
|
||||
inlineEntityCol2.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 450)))));
|
||||
inlineEntityCol2.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
|
||||
|
@ -545,7 +561,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void testConsistency() throws EdmPrimitiveTypeException {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final String cookie = getCookie();
|
||||
|
||||
|
@ -574,7 +590,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Test
|
||||
public void testInvalidType() throws EdmPrimitiveTypeException {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final String cookie = getCookie();
|
||||
|
||||
|
@ -613,7 +629,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
@Test
|
||||
@Ignore
|
||||
public void testDeepInsertOnNavigationPropertyInComplexProperty() {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
||||
final ClientEntity inlineEntity = of.newEntity(ET_TWO_KEY_NAV);
|
||||
|
@ -704,8 +720,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
|
||||
inlineEntitySingle.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
inlineEntitySingle.getProperties().add(of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)))));
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
|
||||
|
@ -726,7 +742,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
|
||||
inlineEntityCol1.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
|
||||
inlineEntityCol1.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
|
||||
|
@ -741,7 +758,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
|
||||
inlineEntityCol2.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
|
||||
inlineEntityCol2.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
|
||||
|
@ -903,4 +921,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI,ContentType.JSON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,960 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
|
||||
import org.apache.olingo.client.api.communication.request.cud.UpdateType;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
|
||||
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.client.api.domain.ClientComplexValue;
|
||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||
import org.apache.olingo.client.api.domain.ClientInlineEntity;
|
||||
import org.apache.olingo.client.api.domain.ClientInlineEntitySet;
|
||||
import org.apache.olingo.client.api.domain.ClientLink;
|
||||
import org.apache.olingo.client.api.domain.ClientObjectFactory;
|
||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||
import org.apache.olingo.client.api.domain.ClientValue;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* see the class comment on {@link DeepInsertITCase}
|
||||
*/
|
||||
public class DeepInsertXmlITCase extends AbstractBaseTestITCase {
|
||||
|
||||
private static final String SERVICE_URI = TecSvcConst.BASE_URI;
|
||||
private static final String SERVICE_NAMESPACE = "olingo.odata.test1";
|
||||
private static final String ES_KEY_NAV = "ESKeyNav";
|
||||
private static final String ES_TWO_KEY_NAV = "ESTwoKeyNav";
|
||||
private static final String ET_KEY_NAV_NAME = "ETKeyNav";
|
||||
private static final String ET_TWO_KEY_NAV_NAME = "ETTwoKeyNav";
|
||||
private static final FullQualifiedName ET_KEY_NAV = new FullQualifiedName(SERVICE_NAMESPACE, ET_KEY_NAV_NAME);
|
||||
private static final FullQualifiedName ET_TWO_KEY_NAV =
|
||||
new FullQualifiedName(SERVICE_NAMESPACE, ET_TWO_KEY_NAV_NAME);
|
||||
private static final String CT_PRIM_COMP = "CTPrimComp";
|
||||
private static final String CT_TWO_PRIM = "CTTwoPrim";
|
||||
private static final String CT_ALL_PRIM = "CTAllPrim";
|
||||
private static final String CT_NAV_FIVE_PROP = "CTNavFiveProp";
|
||||
private static final String CT_BASE_PRIM_COMP_NAV = "CTBasePrimCompNav";
|
||||
private static final String PROPERTY_INT16 = "PropertyInt16";
|
||||
private static final String PROPERTY_STRING = "PropertyString";
|
||||
private static final String PROPERTY_COMP = "PropertyComp";
|
||||
private static final String PROPERTY_COMP_NAV = "PropertyCompNav";
|
||||
private static final String PROPERTY_COMP_COMP_NAV = "PropertyCompCompNav";
|
||||
private static final String PROPERTY_COMP_TWO_PRIM = "PropertyCompTwoPrim";
|
||||
private static final String PROPERTY_COMP_ALL_PRIM = "PropertyCompAllPrim";
|
||||
private static final String NAV_PROPERTY_ET_KEY_NAV_ONE = "NavPropertyETKeyNavOne";
|
||||
private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_ONE = "NavPropertyETTwoKeyNavOne";
|
||||
private static final String NAV_PROPERTY_ET_TWO_KEY_NAV_MANY = "NavPropertyETTwoKeyNavMany";
|
||||
private static final String COL_PROPERTY_STRING = "CollPropertyString";
|
||||
private static final String COL_PROPERTY_COMP_NAV = "CollPropertyCompNav";
|
||||
private static final String EDM_STRING = "Edm.String";
|
||||
|
||||
void assertShortOrInt(int value, Object n) {
|
||||
if (n instanceof Number) {
|
||||
assertEquals(value, ((Number)n).intValue());
|
||||
} else {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeepInsertExpandedResponse() {
|
||||
final ODataClient client = getClient(SERVICE_URI);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
|
||||
|
||||
// Root entity
|
||||
entity.getProperties().add(
|
||||
of.newPrimitiveProperty(PROPERTY_STRING,
|
||||
of.newPrimitiveValueBuilder().buildString("String Property level 0")));
|
||||
entity.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 41)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
|
||||
"String Property level 0, complex level 1")))));
|
||||
|
||||
// First level NavPropertyETTwoKeyNavOne => Type ETTwoKeyNav
|
||||
final ClientEntity firstLevelTwoKeyNav = of.newEntity(ET_TWO_KEY_NAV);
|
||||
firstLevelTwoKeyNav.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
|
||||
"String Property level 1, complex level 1")))));
|
||||
firstLevelTwoKeyNav.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
firstLevelTwoKeyNav.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
|
||||
final ClientInlineEntity firstLevelTwoKeyOneInline =
|
||||
of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, firstLevelTwoKeyNav);
|
||||
entity.addLink(firstLevelTwoKeyOneInline);
|
||||
|
||||
// Second level NavPropertyETTwoKeyNavOne => Type ETTwoKeyNav
|
||||
final ClientEntity secondLevelTwoKeyNav = of.newEntity(ET_TWO_KEY_NAV);
|
||||
secondLevelTwoKeyNav.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 421)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
|
||||
"String Property level 2, complex level 1")))));
|
||||
secondLevelTwoKeyNav.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
secondLevelTwoKeyNav.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
|
||||
|
||||
// Binding links
|
||||
secondLevelTwoKeyNav.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, client.newURIBuilder(
|
||||
SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(new LinkedHashMap<String, Object>() {
|
||||
private static final long serialVersionUID = 3109256773218160485L;
|
||||
{
|
||||
put(PROPERTY_INT16, 3);
|
||||
put(PROPERTY_STRING, "1");
|
||||
}
|
||||
}).build()));
|
||||
|
||||
final ClientInlineEntity secondLevelTwoKeyOneInline =
|
||||
of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, secondLevelTwoKeyNav);
|
||||
firstLevelTwoKeyNav.addLink(secondLevelTwoKeyOneInline);
|
||||
|
||||
// Third level NavPropertyETTwoKeyNavMany => Type ETTwoKeyNav
|
||||
final ClientEntity thirdLevelTwoKeyNavMany1 = of.newEntity(ET_TWO_KEY_NAV);
|
||||
thirdLevelTwoKeyNavMany1.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
|
||||
"String Property level 3, complex level 1")))));
|
||||
thirdLevelTwoKeyNavMany1.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
thirdLevelTwoKeyNavMany1.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
|
||||
|
||||
final ClientEntity thirdLevelTwoKeyNavMany2 = of.newEntity(ET_TWO_KEY_NAV);
|
||||
thirdLevelTwoKeyNavMany2.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 432)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
|
||||
"String Property level 3, complex level 1")))));
|
||||
thirdLevelTwoKeyNavMany2.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
thirdLevelTwoKeyNavMany2.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
|
||||
|
||||
final ClientEntitySet entitySetThirdLevelTwoKeyNavMany = of.newEntitySet();
|
||||
entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany1);
|
||||
entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany2);
|
||||
secondLevelTwoKeyNav.addLink(of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
|
||||
entitySetThirdLevelTwoKeyNavMany));
|
||||
|
||||
// First level NavPropertyETTwoKeyNavMany => Type ETTwoKeyNav
|
||||
final ClientEntity firstLevelTwoKeyNavMany1 = of.newEntity(ET_TWO_KEY_NAV);
|
||||
firstLevelTwoKeyNavMany1.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 422)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString(
|
||||
"String Property level 1, complex level 1")))));
|
||||
firstLevelTwoKeyNavMany1.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
firstLevelTwoKeyNavMany1.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
|
||||
|
||||
final ClientEntitySet entitySetfirstLevelTwoKeyNavMany = of.newEntitySet();
|
||||
entitySetfirstLevelTwoKeyNavMany.getEntities().add(firstLevelTwoKeyNavMany1);
|
||||
entity.addLink(of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
|
||||
entitySetfirstLevelTwoKeyNavMany));
|
||||
|
||||
final ODataEntityCreateResponse<ClientEntity> createResponse =
|
||||
client.getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
|
||||
|
||||
// Check response
|
||||
final ClientEntity resultEntityFirstLevel =
|
||||
createResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE)
|
||||
.asInlineEntity().getEntity();
|
||||
assertEquals(42, resultEntityFirstLevel.getProperty(PROPERTY_COMP_TWO_PRIM)
|
||||
.getComplexValue().get(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toValue());
|
||||
assertEquals("String Property level 1, complex level 1",
|
||||
resultEntityFirstLevel.getProperty(PROPERTY_COMP_TWO_PRIM)
|
||||
.getComplexValue().get(PROPERTY_STRING)
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
final ClientEntity resultEntitySecondLevel =
|
||||
resultEntityFirstLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE).asInlineEntity().getEntity();
|
||||
assertEquals(421, resultEntitySecondLevel.getProperty(PROPERTY_COMP_TWO_PRIM)
|
||||
.getComplexValue().get(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toValue());
|
||||
assertEquals("String Property level 2, complex level 1", resultEntitySecondLevel
|
||||
.getProperty(PROPERTY_COMP_TWO_PRIM)
|
||||
.getComplexValue().get(PROPERTY_STRING)
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
final ClientEntitySet thirdLevelEntitySetNavMany =
|
||||
resultEntitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
|
||||
.asInlineEntitySet().getEntitySet();
|
||||
assertEquals(2, thirdLevelEntitySetNavMany.getEntities().size());
|
||||
|
||||
assertEquals(431, thirdLevelEntitySetNavMany.getEntities().get(0).getProperty(PROPERTY_COMP_TWO_PRIM)
|
||||
.getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("String Property level 3, complex level 1", thirdLevelEntitySetNavMany.getEntities().get(0)
|
||||
.getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
assertEquals(432, thirdLevelEntitySetNavMany.getEntities().get(1).getProperty(PROPERTY_COMP_TWO_PRIM)
|
||||
.getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("String Property level 3, complex level 1", thirdLevelEntitySetNavMany.getEntities().get(1)
|
||||
.getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
final ClientEntitySet firstLevelEntitySetNavMany =
|
||||
createResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
|
||||
.asInlineEntitySet().getEntitySet();
|
||||
assertEquals(1, firstLevelEntitySetNavMany.getEntities().size());
|
||||
assertEquals(422, firstLevelEntitySetNavMany.getEntities().get(0).getProperty(PROPERTY_COMP_TWO_PRIM)
|
||||
.getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("String Property level 1, complex level 1", firstLevelEntitySetNavMany.getEntities().get(0)
|
||||
.getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue()
|
||||
.get(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleDeepInsert() throws EdmPrimitiveTypeException {
|
||||
final ODataClient client = getClient();
|
||||
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final ClientEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
|
||||
|
||||
// Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
|
||||
entity.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)));
|
||||
entity.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_ALL_PRIM, of.newComplexValue(CT_ALL_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16,
|
||||
of.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
|
||||
|
||||
// Non collection navigation property
|
||||
// Create related entity(EntitySet: ESTwoKeyNav, Type: ETTwoKeyNav, Nav. Property: NavPropertyETTwoKeyNavOne)
|
||||
final ClientEntity inlineEntitySingle = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
|
||||
inlineEntitySingle.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 430)))));
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 432)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("432")))));
|
||||
|
||||
// Collection navigation property
|
||||
// The navigation property has a partner navigation property named "NavPropertyETKeyNavOne"
|
||||
// Create related entity(EntitySet: ESTwoKeyNav, Type: NavPropertyETTwoKeyNavMany
|
||||
final ClientEntity inlineEntityCol1 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
|
||||
inlineEntityCol1.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 44)));
|
||||
inlineEntityCol1.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("44")));
|
||||
inlineEntityCol1.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
|
||||
inlineEntityCol1.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 440)))));
|
||||
inlineEntityCol1.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("442")))));
|
||||
|
||||
final ClientEntity inlineEntityCol2 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
|
||||
inlineEntityCol2.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 45)));
|
||||
inlineEntityCol2.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("45")));
|
||||
inlineEntityCol2.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
|
||||
inlineEntityCol2.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 450)))));
|
||||
inlineEntityCol2.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("452")))));
|
||||
|
||||
final ClientInlineEntity newDeepInsertEntityLink =
|
||||
of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntitySingle);
|
||||
final ClientEntitySet newDeepInsertEntitySet = of.newEntitySet();
|
||||
newDeepInsertEntitySet.getEntities().add(inlineEntityCol1);
|
||||
newDeepInsertEntitySet.getEntities().add(inlineEntityCol2);
|
||||
final ClientInlineEntitySet newDeepInsertEntitySetLink =
|
||||
of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, newDeepInsertEntitySet);
|
||||
|
||||
entity.addLink(newDeepInsertEntityLink);
|
||||
entity.addLink(newDeepInsertEntitySetLink);
|
||||
|
||||
// Perform create request
|
||||
final ODataEntityCreateResponse<ClientEntity> responseCreate = client.getCUDRequestFactory()
|
||||
.getEntityCreateRequest(createURI, entity)
|
||||
.execute();
|
||||
assertEquals(HttpStatusCode.CREATED.getStatusCode(), responseCreate.getStatusCode());
|
||||
|
||||
final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).toString();
|
||||
|
||||
// Fetch ESKeyNav entity with expand of NavPropertyETTwoKeyNavOne nav. property
|
||||
ClientProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
|
||||
final URI esKeyNavURI =
|
||||
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
|
||||
propertyInt16.getPrimitiveValue().toValue()).expand(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
|
||||
NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build();
|
||||
|
||||
final ODataEntityRequest<ClientEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
|
||||
.getEntityRequest(esKeyNavURI);
|
||||
esKeyNavRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> esKeyNavResponse = esKeyNavRequest.execute();
|
||||
|
||||
ClientEntity clientEntity = esKeyNavResponse.getBody();
|
||||
// Check nav. property NavPropertyETTwoKeyNavOne
|
||||
assertNotNull(clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
|
||||
ClientInlineEntity navOne = (ClientInlineEntity)clientEntity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE);
|
||||
assertShortOrInt(431, navOne.getEntity().getProperty(
|
||||
PROPERTY_COMP_NAV).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
|
||||
// Check nav. property NavPropertyETTwoKeyNavMany
|
||||
assertNotNull(esKeyNavResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
|
||||
ClientInlineEntitySet navMany = (ClientInlineEntitySet)clientEntity
|
||||
.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY);
|
||||
assertEquals(2, navMany.getEntitySet().getEntities().size());
|
||||
|
||||
assertShortOrInt(441, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_COMP_NAV)
|
||||
.getValue().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(451, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_COMP_NAV)
|
||||
.getValue().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
|
||||
// Fetch ESTwoKeyNav entities and check if available and the partner relation have been set up
|
||||
// Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavOne)
|
||||
Map<String, Object> composedKey = new HashMap<String, Object>();
|
||||
composedKey.put(PROPERTY_INT16, navOne.getEntity().getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toValue());
|
||||
composedKey.put(PROPERTY_STRING, navOne.getEntity().getProperty(PROPERTY_STRING)
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
final URI esTwoKeyNavEntitySingleURI = client.newURIBuilder(SERVICE_URI)
|
||||
.appendEntitySetSegment(ES_TWO_KEY_NAV)
|
||||
.appendKeySegment(composedKey)
|
||||
.build();
|
||||
final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
|
||||
.getEntityRequest(esTwoKeyNavEntitySingleURI);
|
||||
esTwoKeyNavSingleRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
|
||||
assertShortOrInt(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue()
|
||||
.get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
|
||||
// Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(0))
|
||||
composedKey.clear();
|
||||
composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toValue());
|
||||
composedKey.put(PROPERTY_STRING, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_STRING)
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
URI esTwoKeyNavEntityManyOneURI =
|
||||
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
|
||||
.expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
|
||||
|
||||
final ODataEntityRequest<ClientEntity> esTwoKeyNavManyOneRequest =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
|
||||
esTwoKeyNavManyOneRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
|
||||
|
||||
assertShortOrInt(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV)
|
||||
.getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
|
||||
assertNotNull(esTwoKeyNavManyOneResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
|
||||
ClientInlineEntity nvLink = (ClientInlineEntity)esTwoKeyNavManyOneResponse.getBody()
|
||||
.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
|
||||
assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
// Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(1))
|
||||
composedKey.clear();
|
||||
composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toValue());
|
||||
composedKey.put(PROPERTY_STRING, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_STRING)
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
URI esTwoKeyNavEntityManyTwoURI =
|
||||
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
|
||||
.expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
|
||||
|
||||
final ODataEntityRequest<ClientEntity> esTwoKeyNavManyTwoRequest =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
|
||||
esTwoKeyNavManyTwoRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
|
||||
|
||||
assertShortOrInt(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV)
|
||||
.getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
|
||||
|
||||
nvLink = (ClientInlineEntity)esTwoKeyNavManyTwoResponse.getBody()
|
||||
.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
|
||||
assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeepInsertSameEntitySet() throws EdmPrimitiveTypeException {
|
||||
final ODataClient client = getClient();
|
||||
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final ClientEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
|
||||
|
||||
// Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
|
||||
entity.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)));
|
||||
entity.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_ALL_PRIM, of.newComplexValue(CT_ALL_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16,
|
||||
of.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
|
||||
entity.addLink(of.newEntityNavigationLink("NavPropertyETTwoKeyNavOne",
|
||||
client.newURIBuilder(SERVICE_URI)
|
||||
.appendEntitySetSegment(ES_TWO_KEY_NAV)
|
||||
.appendKeySegment(new LinkedHashMap<String, Object>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
put(PROPERTY_INT16, 1);
|
||||
put(PROPERTY_STRING, "1");
|
||||
}
|
||||
})
|
||||
.build()));
|
||||
|
||||
// Prepare inline entity(EntitySet: ESKeyNav, Type: ETKeyNav)
|
||||
final ClientEntity innerEntity = of.newEntity(ET_KEY_NAV);
|
||||
innerEntity.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
|
||||
innerEntity.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
|
||||
innerEntity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
|
||||
innerEntity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_ALL_PRIM, of.newComplexValue(CT_ALL_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("431")))));
|
||||
innerEntity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("431")))));
|
||||
innerEntity
|
||||
.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("431")))
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder()
|
||||
.buildInt16((short) 431)))))));
|
||||
innerEntity.addLink(of.newEntityNavigationLink("NavPropertyETTwoKeyNavOne",
|
||||
client.newURIBuilder(SERVICE_URI)
|
||||
.appendEntitySetSegment(ES_TWO_KEY_NAV)
|
||||
.appendKeySegment(new LinkedHashMap<String, Object>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
put(PROPERTY_INT16, 1);
|
||||
put(PROPERTY_STRING, "1");
|
||||
}
|
||||
})
|
||||
.build()));
|
||||
|
||||
ClientInlineEntity inlineEntity = of.newDeepInsertEntity(NAV_PROPERTY_ET_KEY_NAV_ONE, innerEntity);
|
||||
entity.addLink(inlineEntity);
|
||||
|
||||
final ODataEntityCreateResponse<ClientEntity> responseCreate =
|
||||
client.getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
|
||||
final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).iterator().next();
|
||||
final Short esKeyNavEntityKey =
|
||||
responseCreate.getBody().getProperty(PROPERTY_INT16).getPrimitiveValue().toCastValue(Short.class);
|
||||
|
||||
// Fetch Entity
|
||||
URI fetchEntityURI =
|
||||
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(esKeyNavEntityKey)
|
||||
.expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
|
||||
|
||||
ODataEntityRequest<ClientEntity> entityRequest =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(fetchEntityURI);
|
||||
entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
|
||||
|
||||
ClientEntity clientEntity = entityResponse.getBody();
|
||||
ClientInlineEntity navOne =
|
||||
(ClientInlineEntity) clientEntity.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
|
||||
|
||||
// Check values
|
||||
assertShortOrInt(431, navOne.getEntity().getProperty(PROPERTY_COMP_NAV).getComplexValue()
|
||||
.get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
|
||||
Short innerEntityInt16Key = navOne.getEntity().getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toCastValue(Short.class);
|
||||
|
||||
final URI innerEntityURI =
|
||||
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(innerEntityInt16Key)
|
||||
.build();
|
||||
final ODataEntityRequest<ClientEntity> innerRequest =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(innerEntityURI);
|
||||
innerRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
ODataRetrieveResponse<ClientEntity> innerResponse = innerRequest.execute();
|
||||
|
||||
assertShortOrInt(431, innerResponse.getBody().getProperty(PROPERTY_COMP_NAV)
|
||||
.getComplexValue().get(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConsistency() throws EdmPrimitiveTypeException {
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final String cookie = getCookie();
|
||||
|
||||
// Do not set PropertyString(Nullable=false)
|
||||
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
|
||||
entity.getProperties().add(
|
||||
of.newCollectionProperty(COL_PROPERTY_STRING,
|
||||
of.newCollectionValue(EDM_STRING).add(
|
||||
of.newPrimitiveValueBuilder().buildString("Test"))));
|
||||
|
||||
final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
|
||||
|
||||
try {
|
||||
ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
|
||||
.getEntityCreateRequest(targetURI, entity);
|
||||
request.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
request.execute();
|
||||
fail("Expecting bad request");
|
||||
} catch (ODataClientErrorException e) {
|
||||
assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
// Entity must not be created
|
||||
validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidType() throws EdmPrimitiveTypeException {
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final String cookie = getCookie();
|
||||
|
||||
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
|
||||
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING,
|
||||
of.newPrimitiveValueBuilder().buildInt32(1)));
|
||||
final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
|
||||
|
||||
try {
|
||||
ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
|
||||
.getEntityCreateRequest(targetURI, entity);
|
||||
request.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
request.execute();
|
||||
} catch (ODataClientErrorException e) {
|
||||
assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
|
||||
|
||||
entity.getProperties().add(
|
||||
of.newCollectionProperty(PROPERTY_STRING,
|
||||
of.newCollectionValue(EDM_STRING).add(
|
||||
of.newPrimitiveValueBuilder().buildString("Test"))));
|
||||
|
||||
try {
|
||||
ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
|
||||
.getEntityCreateRequest(targetURI, entity);
|
||||
request.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
request.execute();
|
||||
} catch (ODataClientErrorException e) {
|
||||
assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testDeepInsertOnNavigationPropertyInComplexProperty() {
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
|
||||
final ClientEntity inlineEntity = of.newEntity(ET_TWO_KEY_NAV);
|
||||
inlineEntity.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
inlineEntity.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
|
||||
inlineEntity.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 1)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("1")))));
|
||||
|
||||
final ClientEntity entity = of.newEntity(ET_TWO_KEY_NAV);
|
||||
entity.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
|
||||
entity.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
|
||||
entity.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 2)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("2")))));
|
||||
|
||||
final ClientLink link = of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntity);
|
||||
final ClientComplexValue complexValueCreate = of.newComplexValue(CT_NAV_FIVE_PROP);
|
||||
complexValueCreate.getNavigationLinks().add(link);
|
||||
|
||||
entity.getProperties().add(
|
||||
of.newCollectionProperty(COL_PROPERTY_COMP_NAV, of.newCollectionValue(CT_NAV_FIVE_PROP)
|
||||
.add(complexValueCreate)));
|
||||
|
||||
final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).build();
|
||||
final ODataEntityCreateResponse<ClientEntity> response = client.getCUDRequestFactory()
|
||||
.getEntityCreateRequest(targetURI, entity)
|
||||
.execute();
|
||||
|
||||
assertEquals(HttpStatusCode.CREATED.getStatusCode(), response.getStatusCode());
|
||||
final Iterator<ClientValue> iter = response.getBody()
|
||||
.getProperty(COL_PROPERTY_COMP_NAV)
|
||||
.getCollectionValue()
|
||||
.iterator();
|
||||
|
||||
assertTrue(iter.hasNext());
|
||||
final ClientComplexValue complexValue = iter.next().asComplex();
|
||||
final ClientLink linkedEntity = complexValue.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE);
|
||||
assertNotNull(linkedEntity);
|
||||
assertEquals(1, linkedEntity.asInlineEntity()
|
||||
.getEntity()
|
||||
.getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue()
|
||||
.toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeepUpsert() {
|
||||
final ODataClient client = getClient();
|
||||
final URI updateURI = client.newURIBuilder(SERVICE_URI)
|
||||
.appendEntitySetSegment(ES_KEY_NAV)
|
||||
.appendKeySegment(815)
|
||||
.build();
|
||||
final ClientObjectFactory of = client.getObjectFactory();
|
||||
final ClientEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
|
||||
|
||||
// Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
|
||||
entity.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)));
|
||||
entity.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_ALL_PRIM, of.newComplexValue(CT_ALL_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))));
|
||||
entity.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("42")))
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_NAV_FIVE_PROP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16,
|
||||
of.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
|
||||
|
||||
// Non collection navigation property
|
||||
// Create related entity(EntitySet: ESTwoKeyNav, Type: ETTwoKeyNav, Nav. Property: NavPropertyETTwoKeyNavOne)
|
||||
final ClientEntity inlineEntitySingle = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("43")));
|
||||
inlineEntitySingle.getProperties().add(of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)))));
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))));
|
||||
inlineEntitySingle.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 432)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("432")))));
|
||||
|
||||
// Collection navigation property
|
||||
// The navigation property has a partner navigation property named "NavPropertyETKeyNavOne"
|
||||
// Create related entity(EntitySet: ESTwoKeyNav, Type: NavPropertyETTwoKeyNavMany
|
||||
final ClientEntity inlineEntityCol1 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
|
||||
inlineEntityCol1.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 44)));
|
||||
inlineEntityCol1.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("44")));
|
||||
inlineEntityCol1.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
|
||||
inlineEntityCol1.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 441)))));
|
||||
inlineEntityCol1.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("442")))));
|
||||
|
||||
final ClientEntity inlineEntityCol2 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
|
||||
inlineEntityCol2.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 45)));
|
||||
inlineEntityCol2.getProperties()
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("45")));
|
||||
inlineEntityCol2.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
|
||||
inlineEntityCol2.getProperties().add(
|
||||
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 451)))));
|
||||
inlineEntityCol2.getProperties()
|
||||
.add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
|
||||
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
|
||||
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("452")))));
|
||||
|
||||
final ClientInlineEntity newDeepInsertEntityLink =
|
||||
of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntitySingle);
|
||||
final ClientEntitySet newDeepInsertEntitySet = of.newEntitySet();
|
||||
newDeepInsertEntitySet.getEntities().add(inlineEntityCol1);
|
||||
newDeepInsertEntitySet.getEntities().add(inlineEntityCol2);
|
||||
final ClientInlineEntitySet newDeepInsertEntitySetLink =
|
||||
of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, newDeepInsertEntitySet);
|
||||
|
||||
entity.addLink(newDeepInsertEntityLink);
|
||||
entity.addLink(newDeepInsertEntitySetLink);
|
||||
|
||||
// Perform update request (upsert)
|
||||
final ODataEntityUpdateResponse<ClientEntity> responseCreate = client.getCUDRequestFactory()
|
||||
.getEntityUpdateRequest(updateURI, UpdateType.PATCH, entity)
|
||||
.execute();
|
||||
assertEquals(HttpStatusCode.CREATED.getStatusCode(), responseCreate.getStatusCode());
|
||||
|
||||
final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).toString();
|
||||
|
||||
// Fetch ESKeyNav entity with expand of NavPropertyETTwoKeyNavOne nav. property
|
||||
ClientProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
|
||||
final URI esKeyNavURI =
|
||||
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
|
||||
propertyInt16.getPrimitiveValue().toValue()).expand(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
|
||||
NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build();
|
||||
|
||||
final ODataEntityRequest<ClientEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
|
||||
.getEntityRequest(esKeyNavURI);
|
||||
esKeyNavRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> esKeyNavResponse = esKeyNavRequest.execute();
|
||||
|
||||
// Check nav. property NavPropertyETTwoKeyNavOne
|
||||
assertNotNull(esKeyNavResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
|
||||
ClientInlineEntity navOne = (ClientInlineEntity)esKeyNavResponse.getBody()
|
||||
.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE);
|
||||
assertShortOrInt(431, navOne.getEntity().getProperty(PROPERTY_COMP_NAV).getComplexValue()
|
||||
.get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
|
||||
// Check nav. property NavPropertyETTwoKeyNavMany
|
||||
assertNotNull(esKeyNavResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
|
||||
ClientInlineEntitySet navMany = (ClientInlineEntitySet)esKeyNavResponse.getBody()
|
||||
.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY);
|
||||
assertEquals(2, navMany.getEntitySet().getEntities().size());
|
||||
|
||||
assertShortOrInt(441, navMany.getEntitySet().getEntities().get(0).getProperty(PROPERTY_COMP_NAV).getValue()
|
||||
.asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
|
||||
assertShortOrInt(451, navMany.getEntitySet().getEntities().get(1).getProperty(PROPERTY_COMP_NAV).getValue()
|
||||
.asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
|
||||
// Fetch ESTwoKeyNav entities and check if available and the partner relation have been set up
|
||||
// Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavOne)
|
||||
Map<String, Object> composedKey = new HashMap<String, Object>();
|
||||
composedKey.put(PROPERTY_INT16, navOne.getEntity().getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toValue());
|
||||
composedKey.put(PROPERTY_STRING, navOne.getEntity().getProperty(PROPERTY_STRING)
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
final URI esTwoKeyNavEntitySingleURI = client.newURIBuilder(SERVICE_URI)
|
||||
.appendEntitySetSegment(ES_TWO_KEY_NAV)
|
||||
.appendKeySegment(composedKey)
|
||||
.build();
|
||||
|
||||
final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
|
||||
.getEntityRequest(esTwoKeyNavEntitySingleURI);
|
||||
esTwoKeyNavSingleRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
|
||||
assertShortOrInt(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV)
|
||||
.getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
|
||||
// Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(0))
|
||||
composedKey.clear();
|
||||
composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(0)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
composedKey.put(PROPERTY_STRING,navMany.getEntitySet().getEntities().get(0)
|
||||
.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
URI esTwoKeyNavEntityManyOneURI =
|
||||
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
|
||||
.expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
|
||||
|
||||
final ODataEntityRequest<ClientEntity> esTwoKeyNavManyOneRequest =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
|
||||
esTwoKeyNavManyOneRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
|
||||
|
||||
assertShortOrInt(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV)
|
||||
.getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertNotNull(esTwoKeyNavManyOneResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
|
||||
ClientInlineEntity nvLink = (ClientInlineEntity)esTwoKeyNavManyOneResponse.getBody()
|
||||
.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
|
||||
assertEquals(propertyInt16.getPrimitiveValue().toValue(), nvLink.getEntity().getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
// Check ESTwoKeyNav(Created via NavPropertyETTwoKeyNavMany(1))
|
||||
composedKey.clear();
|
||||
composedKey.put(PROPERTY_INT16, navMany.getEntitySet().getEntities().get(1)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
composedKey.put(PROPERTY_STRING,navMany.getEntitySet().getEntities().get(1)
|
||||
.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
URI esTwoKeyNavEntityManyTwoURI =
|
||||
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
|
||||
.expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
|
||||
|
||||
final ODataEntityRequest<ClientEntity> esTwoKeyNavManyTwoRequest =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
|
||||
esTwoKeyNavManyTwoRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
|
||||
|
||||
assertShortOrInt(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV)
|
||||
.getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
|
||||
nvLink = (ClientInlineEntity)esTwoKeyNavManyTwoResponse.getBody()
|
||||
.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE);
|
||||
assertEquals(propertyInt16.getPrimitiveValue().toValue(),nvLink.getEntity()
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
private String getCookie() {
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
|
||||
.getEntitySetRequest(client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build())
|
||||
.execute();
|
||||
|
||||
return response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
|
||||
}
|
||||
|
||||
private void validateSet(final URI uri, final String cookie, final short... keys)
|
||||
throws EdmPrimitiveTypeException {
|
||||
final EdmEnabledODataClient client = getClient(SERVICE_URI);
|
||||
final ODataEntitySetRequest<ClientEntitySet> request = client.getRetrieveRequestFactory()
|
||||
.getEntitySetRequest(uri);
|
||||
request.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
|
||||
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
assertEquals(3, response.getBody().getEntities().size());
|
||||
|
||||
for (final ClientEntity responseEntity : response.getBody().getEntities()) {
|
||||
short propertyInt16 = responseEntity.getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue().toCastValue(Short.class);
|
||||
|
||||
boolean found = false;
|
||||
for (int i = 0; i < keys.length && !found; i++) {
|
||||
if (propertyInt16 == keys[i]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
fail("Invalid key " + propertyInt16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -37,6 +37,7 @@ import org.apache.olingo.client.api.communication.response.ODataReferenceAddingR
|
|||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||
import org.apache.olingo.client.api.domain.ClientInlineEntity;
|
||||
import org.apache.olingo.client.api.uri.QueryOption;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
@ -44,6 +45,7 @@ import org.apache.olingo.commons.api.http.HttpHeader;
|
|||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
||||
|
@ -63,6 +65,15 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
private static final String PROPERTY_INT16 = "PropertyInt16";
|
||||
private static final String PROPERTY_STRING = "PropertyString";
|
||||
|
||||
|
||||
void assertShortOrInt(int value, Object n) {
|
||||
if (n instanceof Number) {
|
||||
assertEquals(value, ((Number)n).intValue());
|
||||
} else {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrderBy() {
|
||||
final ODataClient client = getClient();
|
||||
|
@ -249,9 +260,12 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
.asInlineEntitySet()
|
||||
.getEntitySet();
|
||||
assertEquals(3, inlineEntitySet.getEntities().size());
|
||||
assertEquals(1, inlineEntitySet.getEntities().get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals(2, inlineEntitySet.getEntities().get(1).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals(3, inlineEntitySet.getEntities().get(2).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, inlineEntitySet.getEntities().get(0)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, inlineEntitySet.getEntities().get(1)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, inlineEntitySet.getEntities().get(2)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -287,9 +301,12 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
.asInlineEntitySet()
|
||||
.getEntitySet();
|
||||
assertEquals(3, inlineEntitySet.getEntities().size());
|
||||
assertEquals(1, inlineEntitySet.getEntities().get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals(2, inlineEntitySet.getEntities().get(1).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals(3, inlineEntitySet.getEntities().get(2).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, inlineEntitySet.getEntities().get(0)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, inlineEntitySet.getEntities().get(1)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, inlineEntitySet.getEntities().get(2)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -385,7 +402,7 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
final ODataRetrieveResponse<ClientEntity> responseGet = requestGet.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), responseGet.getStatusCode());
|
||||
|
||||
assertEquals(3, responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE)
|
||||
assertShortOrInt(3, responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE)
|
||||
.asInlineEntity()
|
||||
.getEntity()
|
||||
.getProperty(PROPERTY_INT16)
|
||||
|
@ -419,7 +436,7 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
final ODataRetrieveResponse<ClientEntity> responseGet = requestGet.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), responseGet.getStatusCode());
|
||||
|
||||
assertEquals(3, responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE)
|
||||
assertShortOrInt(3, responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE)
|
||||
.asInlineEntity()
|
||||
.getEntity()
|
||||
.getProperty(PROPERTY_INT16)
|
||||
|
@ -595,7 +612,8 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE)
|
||||
.asInlineEntity().getEntity();
|
||||
|
||||
assertEquals(3, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().asPrimitive().toValue());
|
||||
assertShortOrInt(3, inlineEntity.getProperty(PROPERTY_INT16)
|
||||
.getPrimitiveValue().asPrimitive().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -645,9 +663,12 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
.getEntitySet();
|
||||
|
||||
assertEquals(3, inlineEntitySet.getEntities().size());
|
||||
assertEquals(1, inlineEntitySet.getEntities().get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals(2, inlineEntitySet.getEntities().get(1).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals(3, inlineEntitySet.getEntities().get(2).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, inlineEntitySet.getEntities().get(0)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, inlineEntitySet.getEntities().get(1)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, inlineEntitySet.getEntities().get(2)
|
||||
.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -673,13 +694,13 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
requestGet.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> responseGet = requestGet.execute();
|
||||
|
||||
assertEquals(1, responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY)
|
||||
assertShortOrInt(1, responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY)
|
||||
.asInlineEntitySet()
|
||||
.getEntitySet()
|
||||
.getEntities()
|
||||
.size());
|
||||
|
||||
assertEquals(2, responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY)
|
||||
assertShortOrInt(2, responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY)
|
||||
.asInlineEntitySet()
|
||||
.getEntitySet()
|
||||
.getEntities()
|
||||
|
@ -711,7 +732,14 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
requestGet.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> responseGet = requestGet.execute();
|
||||
|
||||
assertEquals(0, responseGet.getBody().getNavigationLinks().size());
|
||||
|
||||
if(isJson()) {
|
||||
assertEquals(0, responseGet.getBody().getNavigationLinks().size());
|
||||
} else {
|
||||
// in xml the links will be always present; but the content will not be if no $expand unlike
|
||||
// json;metadata=minimal; json=full is same as application/xml
|
||||
assertEquals(6, responseGet.getBody().getNavigationLinks().size());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -807,7 +835,11 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), ex.getStatusLine().getStatusCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isJson() {
|
||||
return getClient().getConfiguration().getDefaultPubFormat().equals(ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNavigateTwoTimesThanDeleteReferenceInCollection() {
|
||||
final ODataClient client = getClient();
|
||||
|
@ -834,8 +866,15 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
final ODataEntityRequest<ClientEntity> requestGet = client.getRetrieveRequestFactory().getEntityRequest(uriGet);
|
||||
requestGet.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> responseGet = requestGet.execute();
|
||||
if(isJson()) {
|
||||
assertNull(responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
|
||||
} else {
|
||||
// in xml the links will be always present; but the content will not be if no $expand unlike
|
||||
// json;metadata=minimal; json=full is same as application/xml
|
||||
Assert.assertFalse(responseGet.getBody()
|
||||
.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE) instanceof ClientInlineEntity);
|
||||
}
|
||||
|
||||
assertNull(responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -872,7 +911,7 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
.getEntities()
|
||||
.size());
|
||||
|
||||
assertEquals(3, responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY)
|
||||
assertShortOrInt(3, responseGet.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY)
|
||||
.asInlineEntitySet()
|
||||
.getEntitySet()
|
||||
.getEntities()
|
||||
|
@ -908,7 +947,15 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
getRequestESTwoKeyNav.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> responseGetRequestESTwoKeyNav = getRequestESTwoKeyNav.execute();
|
||||
// Entity has been removed
|
||||
assertNull(responseGetRequestESTwoKeyNav.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
|
||||
if(isJson()) {
|
||||
assertNull(responseGetRequestESTwoKeyNav.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
|
||||
} else {
|
||||
// in xml the links will be always present; but the content will not be if no $expand unlike
|
||||
// json;metadata=minimal; json=full is same as application/xml
|
||||
Assert.assertFalse(responseGetRequestESTwoKeyNav.getBody()
|
||||
.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE) instanceof ClientInlineEntity);
|
||||
}
|
||||
|
||||
|
||||
final URI uriGetESKeyNav = client.newURIBuilder(SERVICE_URI)
|
||||
.appendEntitySetSegment(ES_KEY_NAV)
|
||||
|
@ -929,10 +976,10 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
|
||||
// The Entities in the collection are still there
|
||||
assertEquals(2, navEntities.size());
|
||||
assertEquals(1, navEntities.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, navEntities.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("1", navEntities.get(0).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
assertEquals(1, navEntities.get(1).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, navEntities.get(1).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("2", navEntities.get(1).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -967,7 +1014,7 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
.getEntities();
|
||||
|
||||
assertEquals(1, navEntities.size());
|
||||
assertEquals(1, navEntities.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, navEntities.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("2", navEntities.get(0).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
final Map<String, Object> esTwoKEyNavKey = new HashMap<String, Object>();
|
||||
|
@ -981,7 +1028,15 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
.getEntityRequest(uriGetESTwoKeyNav);
|
||||
requestGetESTwoKey.addCustomHeader(HttpHeader.COOKIE, cookie);
|
||||
final ODataRetrieveResponse<ClientEntity> responseGetESTwoKeyNav = requestGetESTwoKey.execute();
|
||||
assertNull(responseGetESTwoKeyNav.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
|
||||
|
||||
if(isJson()) {
|
||||
assertNull(responseGetESTwoKeyNav.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE));
|
||||
} else {
|
||||
// in xml the links will be always present; but the content will not be if no $expand unlike
|
||||
// json;metadata=minimal; json=full is same as application/xml
|
||||
Assert.assertFalse(responseGetESTwoKeyNav.getBody()
|
||||
.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE) instanceof ClientInlineEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1044,9 +1099,13 @@ public class EntityReferencesITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI, ContentType.JSON);
|
||||
client.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.JSON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class EntityReferencesXmlITCase extends EntityReferencesITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ import static org.junit.Assert.assertNull;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
|
@ -34,13 +35,23 @@ import org.apache.olingo.client.api.domain.ClientLink;
|
|||
import org.apache.olingo.client.api.domain.ClientLinkType;
|
||||
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class ExpandSelectITCase extends AbstractBaseTestITCase {
|
||||
public class ExpandSelectITCase extends AbstractBaseTestITCase {
|
||||
|
||||
void assertShortOrInt(int value, Object n) {
|
||||
if (n instanceof Number) {
|
||||
assertEquals(value, ((Number)n).intValue());
|
||||
} else {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readSelect() {
|
||||
final ODataClient client = getClient();
|
||||
|
@ -64,7 +75,7 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
|
|||
ClientProperty property = entity.getProperty("PropertyInt16");
|
||||
assertNotNull(property);
|
||||
assertNotNull(property.getPrimitiveValue());
|
||||
assertEquals(Integer.valueOf(Short.MAX_VALUE), property.getPrimitiveValue().toValue());
|
||||
assertShortOrInt(Integer.valueOf(Short.MAX_VALUE), property.getPrimitiveValue().toValue());
|
||||
|
||||
property = entity.getProperty("PropertyInt32");
|
||||
assertNotNull(property);
|
||||
|
@ -72,6 +83,10 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(Integer.MAX_VALUE, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
private boolean isJson() {
|
||||
return getClient().getConfiguration().getDefaultPubFormat().equals(ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readExpandSelect() {
|
||||
final ODataClient client = getClient();
|
||||
|
@ -96,7 +111,13 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
|
|||
assertNotNull(property.getPrimitiveValue());
|
||||
assertEquals("Test String2", property.getPrimitiveValue().toValue());
|
||||
|
||||
assertNull(entity.getNavigationLink("NavPropertyETAllPrimOne"));
|
||||
if(isJson()) {
|
||||
assertNull(entity.getNavigationLink("NavPropertyETAllPrimOne"));
|
||||
} else {
|
||||
// in xml the links will be always present; but the content will not be if no $expand unlike
|
||||
// json;metadata=minimal; json=full is same as application/xml
|
||||
Assert.assertFalse(entity.getNavigationLink("NavPropertyETAllPrimOne") instanceof ClientInlineEntity);
|
||||
}
|
||||
|
||||
final ClientLink link = entity.getNavigationLink("NavPropertyETAllPrimMany");
|
||||
assertNotNull(link);
|
||||
|
@ -108,7 +129,7 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(2, entities.size());
|
||||
final ClientEntity inlineEntity = entities.get(0);
|
||||
assertEquals(2, inlineEntity.getProperties().size());
|
||||
assertEquals(-128, inlineEntity.getProperty("PropertySByte").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-128, inlineEntity.getProperty("PropertySByte").getPrimitiveValue().toValue());
|
||||
assertEquals(new java.sql.Timestamp(85754000),
|
||||
inlineEntity.getProperty("PropertyTimeOfDay").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
@ -130,7 +151,13 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
|
|||
assertNotNull(entity);
|
||||
assertEquals(2, entity.getProperties().size());
|
||||
|
||||
assertNull(entity.getNavigationLink("NavPropertyETAllPrimMany"));
|
||||
if(isJson()) {
|
||||
assertNull(entity.getNavigationLink("NavPropertyETAllPrimMany"));
|
||||
} else {
|
||||
// in xml the links will be always present; but the content will not be if no $expand unlike
|
||||
// json;metadata=minimal; json=full is same as application/xml
|
||||
Assert.assertFalse(entity.getNavigationLink("NavPropertyETAllPrimMany") instanceof ClientInlineEntity);
|
||||
}
|
||||
|
||||
final ClientLink link = entity.getNavigationLink("NavPropertyETAllPrimOne");
|
||||
assertNotNull(link);
|
||||
|
@ -145,7 +172,7 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
|
|||
final ClientEntity innerEntity = innerLink.asInlineEntity().getEntity();
|
||||
assertNotNull(innerEntity);
|
||||
assertEquals(2, innerEntity.getProperties().size());
|
||||
assertEquals(32767, innerEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, innerEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("Test String4", innerEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -156,13 +183,26 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
|
|||
.getEntityRequest(client.newURIBuilder(TecSvcConst.BASE_URI)
|
||||
.appendEntitySetSegment("ESKeyNav").appendKeySegment(3).expand("NavPropertyETKeyNavOne").build())
|
||||
.execute();
|
||||
|
||||
assertEquals(0, response.getBody().getNavigationLinks().size());
|
||||
assertNull(response.getBody().getNavigationLink("NavPropertyETKeyNavOne"));
|
||||
|
||||
if(isJson()) {
|
||||
// this will be only true in the json;metadata=minimal case not always
|
||||
assertEquals(0, response.getBody().getNavigationLinks().size());
|
||||
assertNull(response.getBody().getNavigationLink("NavPropertyETKeyNavOne"));
|
||||
} else {
|
||||
// in xml the links will be always present; but the content will not be if no $expand unlike
|
||||
// json;metadata=minimal; json=full is same as application/xml
|
||||
assertEquals(6, response.getBody().getNavigationLinks().size());
|
||||
Assert.assertFalse(response.getBody()
|
||||
.getNavigationLink("NavPropertyETKeyNavOne") instanceof ClientInlineEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
return ODataClientFactory.getEdmEnabledClient(TecSvcConst.BASE_URI);
|
||||
return ODataClientFactory.getEdmEnabledClient(TecSvcConst.BASE_URI, ContentType.JSON);
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.JSON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class ExpandSelectXmlITCase extends ExpandSelectITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -40,6 +40,7 @@ import org.apache.olingo.commons.api.http.HttpHeader;
|
|||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -53,6 +54,14 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
private static final String PROPERTY_INT16 = "PropertyInt16";
|
||||
private static final String PROPERTY_STRING = "PropertyString";
|
||||
|
||||
void assertShortOrInt(int value, Object n) {
|
||||
if (n instanceof Number) {
|
||||
assertEquals(value, ((Number)n).intValue());
|
||||
} else {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilter() {
|
||||
final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
|
||||
|
@ -64,26 +73,26 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(4, entities.size());
|
||||
|
||||
for (final ClientEntity entity : entities) {
|
||||
final Object propInt16 = entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue();
|
||||
final Number propInt16 = (Number)entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue();
|
||||
final Object propString = entity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue();
|
||||
final ClientEntitySet inlineEntitySet =
|
||||
entity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
|
||||
|
||||
if (propInt16.equals(1) && propString.equals("1")) {
|
||||
if (propInt16.intValue() == 1 && propString.equals("1")) {
|
||||
assertEquals(1, inlineEntitySet.getEntities().size());
|
||||
final ClientEntity inlineEntity = inlineEntitySet.getEntities().get(0);
|
||||
|
||||
assertEquals(1, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("2", inlineEntity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
} else if (propInt16.equals(1) && propString.equals("2")) {
|
||||
} else if (propInt16.intValue() == 1 && propString.equals("2")) {
|
||||
assertEquals(0, inlineEntitySet.getEntities().size());
|
||||
} else if (propInt16.equals(2) && propString.equals("1")) {
|
||||
} else if (propInt16.intValue() == 2 && propString.equals("1")) {
|
||||
assertEquals(1, inlineEntitySet.getEntities().size());
|
||||
final ClientEntity inlineEntity = inlineEntitySet.getEntities().get(0);
|
||||
|
||||
assertEquals(1, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("2", inlineEntity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
} else if (propInt16.equals(3) && propString.equals("1")) {
|
||||
} else if (propInt16.intValue() == 3 && propString.equals("1")) {
|
||||
assertEquals(0, inlineEntitySet.getEntities().size());
|
||||
} else {
|
||||
fail();
|
||||
|
@ -196,22 +205,22 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(4, entities.size());
|
||||
|
||||
for (final ClientEntity entity : entities) {
|
||||
final Object propInt16 = entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue();
|
||||
final Number propInt16 = (Number)entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue();
|
||||
final Object propString = entity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue();
|
||||
final ClientEntitySet inlineEntitySet =
|
||||
entity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
|
||||
|
||||
if (propInt16.equals(1) && propString.equals("1")) {
|
||||
if (propInt16.intValue() == 1 && propString.equals("1")) {
|
||||
assertEquals(1, inlineEntitySet.getEntities().size());
|
||||
final ClientEntity inlineEntity = inlineEntitySet.getEntities().get(0);
|
||||
|
||||
assertEquals(1, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("2", inlineEntity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
} else if (propInt16.equals(1) && propString.equals("2")) {
|
||||
} else if (propInt16.intValue() == 1 && propString.equals("2")) {
|
||||
assertEquals(0, inlineEntitySet.getEntities().size());
|
||||
} else if (propInt16.equals(2) && propString.equals("1")) {
|
||||
} else if (propInt16.intValue() == 2 && propString.equals("1")) {
|
||||
assertEquals(0, inlineEntitySet.getEntities().size());
|
||||
} else if (propInt16.equals(3) && propString.equals("1")) {
|
||||
} else if (propInt16.intValue() == 3 && propString.equals("1")) {
|
||||
assertEquals(0, inlineEntitySet.getEntities().size());
|
||||
} else {
|
||||
fail();
|
||||
|
@ -276,7 +285,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
final ClientEntitySet entitySet =
|
||||
response.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
|
||||
assertEquals(1, entitySet.getEntities().size());
|
||||
assertEquals(1, entitySet.getEntities().get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, entitySet.getEntities().get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -336,7 +345,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
.getEntities()
|
||||
.get(0);
|
||||
|
||||
assertEquals(1, entitySecondLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, entitySecondLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("2", entitySecondLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
assertNotNull(entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
|
||||
|
@ -352,7 +361,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
.getEntities()
|
||||
.get(0);
|
||||
|
||||
assertEquals(1, entityThirdLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, entityThirdLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("1", entityThirdLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
assertNotNull(entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
|
||||
|
@ -367,10 +376,10 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
.getEntitySet()
|
||||
.getEntities();
|
||||
|
||||
assertEquals(1, fourthLevelEntites.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, fourthLevelEntites.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("1", fourthLevelEntites.get(0).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
assertEquals(1, fourthLevelEntites.get(1).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, fourthLevelEntites.get(1).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("2", fourthLevelEntites.get(1).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -412,7 +421,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
.getEntities()
|
||||
.get(0);
|
||||
|
||||
assertEquals(1, entitySecondLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, entitySecondLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("2", entitySecondLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
assertNotNull(entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
|
||||
|
@ -428,7 +437,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
.getEntities()
|
||||
.get(0);
|
||||
|
||||
assertEquals(1, entityThirdLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, entityThirdLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("1", entityThirdLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
|
||||
assertNotNull(entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
|
||||
|
@ -443,7 +452,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
.getEntitySet()
|
||||
.getEntities();
|
||||
|
||||
assertEquals(1, fourthLevelEntites.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, fourthLevelEntites.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
|
||||
assertEquals("1", fourthLevelEntites.get(0).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -470,8 +479,12 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
EdmEnabledODataClient odata = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
|
||||
EdmEnabledODataClient odata = ODataClientFactory.getEdmEnabledClient(SERVICE_URI, ContentType.JSON);
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.JSON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class ExpandWithSystemQueryOptionsXmlITCase extends ExpandWithSystemQueryOptionsITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -61,7 +61,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -70,15 +70,15 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(2, response.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
clientEntity = response.getBody().getEntities().get(1);
|
||||
assertEquals(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
|
||||
response = sendRequest(ES_ALL_PRIM, "PropertyBoolean eq true");
|
||||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -87,7 +87,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -97,7 +97,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -108,7 +108,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -120,7 +120,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -129,11 +129,11 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
|
||||
assertEquals(2, result.getBody().getEntities().size());
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("2", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
|
||||
assertEquals(1, result.getBody().getEntities().size());
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
|
||||
assertEquals(1, response.getBody().getEntities().size());
|
||||
ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -183,17 +183,17 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
sendRequest(ES_TWO_KEY_NAV, "PropertyString eq '2' and PropertyInt16 eq 1");
|
||||
assertEquals(1, result.getBody().getEntities().size());
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("2", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
result = sendRequest(ES_TWO_KEY_NAV, "PropertyString eq '2' or PropertyInt16 eq 1");
|
||||
assertEquals(2, result.getBody().getEntities().size());
|
||||
clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("2", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -252,9 +252,8 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
ODataRetrieveResponse<ClientEntitySet> response =
|
||||
sendRequest(ES_ALL_PRIM, "substring(PropertyString, -1, 1) eq 'F'");
|
||||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
assertEquals(32767, response.getBody().getEntities().get(0).getProperty("PropertyInt16").getPrimitiveValue()
|
||||
.toValue());
|
||||
assertShortOrInt(32767, response.getBody().getEntities().get(0).getProperty("PropertyInt16")
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
// -1 should be treated as 0, Same values substring(PropertyString, 0, 0) returns the empty String
|
||||
response = sendRequest(ES_ALL_PRIM, "substring(PropertyString, 0, -1) eq ''");
|
||||
|
@ -344,21 +343,21 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(3, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
assertEquals(11, clientEntity.getProperty("PropertyComp").getComplexValue().get("PropertyInt16")
|
||||
assertShortOrInt(11, clientEntity.getProperty("PropertyComp").getComplexValue().get("PropertyInt16")
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("2", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
assertEquals(11, clientEntity.getProperty("PropertyComp").getComplexValue().get("PropertyInt16")
|
||||
assertShortOrInt(11, clientEntity.getProperty("PropertyComp").getComplexValue().get("PropertyInt16")
|
||||
.getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(2);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
assertEquals(11, clientEntity.getProperty("PropertyComp").getComplexValue().get("PropertyInt16")
|
||||
assertShortOrInt(11, clientEntity.getProperty("PropertyComp").getComplexValue().get("PropertyInt16")
|
||||
.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -368,11 +367,11 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(2, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(2, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -382,11 +381,11 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(2, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(2, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -396,11 +395,11 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(2, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(2, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -430,7 +429,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -441,19 +440,19 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(4, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("2", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(2);
|
||||
assertEquals(2, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(3);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -470,7 +469,15 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
void assertShortOrInt(int value, Object n) {
|
||||
if (n instanceof Number) {
|
||||
assertEquals(value, ((Number)n).intValue());
|
||||
} else {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -479,7 +486,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -488,13 +495,13 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(3, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(2);
|
||||
assertEquals(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -503,7 +510,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -512,13 +519,13 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(3, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(2);
|
||||
assertEquals(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -527,7 +534,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -536,10 +543,10 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(2, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -548,7 +555,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -557,7 +564,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -566,7 +573,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -575,7 +582,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -584,7 +591,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -594,11 +601,11 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(2, response.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("W/\"32767\"", clientEntity.getETag());
|
||||
|
||||
clientEntity = response.getBody().getEntities().get(1);
|
||||
assertEquals(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("W/\"0\"", clientEntity.getETag());
|
||||
}
|
||||
|
||||
|
@ -638,14 +645,14 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
result = sendRequest(ES_TWO_KEY_NAV, "PropertyInt16 eq floor(3.1)");
|
||||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -655,14 +662,14 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
result = sendRequest(ES_TWO_KEY_NAV, "PropertyInt16 eq ceiling(2.6)");
|
||||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -672,28 +679,28 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
result = sendRequest(ES_TWO_KEY_NAV, "PropertyInt16 eq round(2.4)");
|
||||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(2, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
result = sendRequest(ES_TWO_KEY_NAV, "PropertyInt16 eq round(2.6)");
|
||||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
|
||||
result = sendRequest(ES_TWO_KEY_NAV, "PropertyInt16 eq round(3.1)");
|
||||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(3, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("1", clientEntity.getProperty("PropertyString").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
|
@ -703,10 +710,10 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(2, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
|
||||
clientEntity = result.getBody().getEntities().get(1);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -716,7 +723,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -725,7 +732,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -735,7 +742,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -745,7 +752,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -755,7 +762,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -765,7 +772,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(-32768, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -775,7 +782,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, result.getBody().getEntities().size());
|
||||
|
||||
ClientEntity clientEntity = result.getBody().getEntities().get(0);
|
||||
assertEquals(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -793,7 +800,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
final ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -803,7 +810,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
final ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -820,7 +827,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
final ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -830,7 +837,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
final ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -840,7 +847,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
final ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -850,7 +857,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
final ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(32767, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -860,7 +867,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
final ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -870,7 +877,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
assertEquals(1, response.getBody().getEntities().size());
|
||||
|
||||
final ClientEntity clientEntity = response.getBody().getEntities().get(0);
|
||||
assertEquals(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(0, clientEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class FilterSystemQueryXmlITCase extends FilterSystemQueryITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -48,10 +48,19 @@ import org.apache.olingo.commons.api.format.ContentType;
|
|||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FunctionImportITCase extends AbstractBaseTestITCase {
|
||||
|
||||
void assertShortOrInt(int value, Object n) {
|
||||
if (n instanceof Number) {
|
||||
assertEquals(value, ((Number)n).intValue());
|
||||
} else {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entity() throws Exception {
|
||||
final ODataInvokeRequest<ClientEntity> request = getClient().getInvokeRequestFactory()
|
||||
|
@ -67,7 +76,7 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
|
|||
assertNotNull(entity);
|
||||
final ClientProperty property = entity.getProperty("PropertyInt16");
|
||||
assertNotNull(property);
|
||||
assertEquals(1, property.getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -85,7 +94,7 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
|
|||
assertNotNull(entity);
|
||||
final ClientProperty property = entity.getProperty("PropertyInt16");
|
||||
assertNotNull(property);
|
||||
assertEquals(1, property.getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -134,7 +143,7 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
|
|||
final ClientProperty property = entity.getProperty("PropertyInt16");
|
||||
assertNotNull(property);
|
||||
assertNotNull(property.getPrimitiveValue());
|
||||
assertEquals(1, property.getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -155,7 +164,7 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
|
|||
final ClientProperty property = response.getBody();
|
||||
assertNotNull(property);
|
||||
assertNotNull(property.getPrimitiveValue());
|
||||
assertEquals(2, property.getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -181,7 +190,7 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
|
|||
|
||||
final ClientProperty property = response.getBody();
|
||||
assertNotNull(property);
|
||||
assertEquals(16, property.getPrimitiveValue().toValue());
|
||||
assertShortOrInt(16, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -264,11 +273,11 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
|
|||
final Iterator<ClientValue> iter = collection.iterator();
|
||||
|
||||
ClientComplexValue complexValue = iter.next().asComplex();
|
||||
assertEquals(1, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("UFCRTCollCTTwoPrimTwoParam string value: TestString", complexValue.get("PropertyString")
|
||||
.getPrimitiveValue().toValue());
|
||||
complexValue = iter.next().asComplex();
|
||||
assertEquals(2, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("UFCRTCollCTTwoPrimTwoParam string value: TestString", complexValue.get("PropertyString")
|
||||
.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
@ -287,11 +296,11 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
|
|||
final Iterator<ClientValue> iter = collection.iterator();
|
||||
|
||||
ClientComplexValue complexValue = iter.next().asComplex();
|
||||
assertEquals(1, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("UFCRTCollCTTwoPrimTwoParam int16 value: 2", complexValue.get("PropertyString")
|
||||
.getPrimitiveValue().toValue());
|
||||
complexValue = iter.next().asComplex();
|
||||
assertEquals(2, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertShortOrInt(2, complexValue.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
assertEquals("UFCRTCollCTTwoPrimTwoParamstring value: null", complexValue.get("PropertyString")
|
||||
.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class FunctionImportXmlITCase extends FunctionImportITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -47,10 +47,17 @@ import org.apache.olingo.commons.api.http.HttpHeader;
|
|||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public final class MediaITCase extends AbstractBaseTestITCase {
|
||||
|
||||
public class MediaITCase extends AbstractBaseTestITCase {
|
||||
void assertShortOrInt(int value, Object n) {
|
||||
if (n instanceof Number) {
|
||||
assertEquals(value, ((Number)n).intValue());
|
||||
} else {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void read() throws Exception {
|
||||
final ODataClient client = getClient();
|
||||
|
@ -138,7 +145,7 @@ public final class MediaITCase extends AbstractBaseTestITCase {
|
|||
final ClientProperty property = entity.getProperty("PropertyInt16");
|
||||
assertNotNull(property);
|
||||
assertNotNull(property.getPrimitiveValue());
|
||||
assertEquals(5, property.getPrimitiveValue().toValue());
|
||||
assertShortOrInt(5, property.getPrimitiveValue().toValue());
|
||||
|
||||
// Check that the media stream has been created.
|
||||
// This check has to be in the same session in order to access the same data provider.
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class MediaXmlITCase extends MediaITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -22,6 +22,8 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||
|
@ -33,14 +35,22 @@ import org.apache.olingo.commons.api.http.HttpStatusCode;
|
|||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.fit.tecsvc.TecSvcConst;
|
||||
import org.apache.olingo.fit.util.StringHelper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public final class NavigationITCase extends AbstractBaseTestITCase {
|
||||
public class NavigationITCase extends AbstractBaseTestITCase {
|
||||
|
||||
private final ODataClient client = getClient();
|
||||
|
||||
|
||||
void assertShortOrInt(int value, Object n) {
|
||||
if (n instanceof Number) {
|
||||
assertEquals(value, ((Number)n).intValue());
|
||||
} else {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void navigationToEntityWithRelativeContextUrl() throws Exception {
|
||||
// zero navigation
|
||||
|
@ -50,7 +60,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
|
|||
appendKeySegment(32767).build()).rawExecute();
|
||||
|
||||
String zeroLevelResponseBody = StringHelper.asString(zeroLevelResponse);
|
||||
assertTrue(zeroLevelResponseBody.contains("\"@odata.context\":\"$metadata#ESAllPrim/$entity\""));
|
||||
assertTrue(zeroLevelResponseBody.contains("\"$metadata#ESAllPrim/$entity\""));
|
||||
|
||||
// one navigation
|
||||
final InputStream oneLevelResponse = client.getRetrieveRequestFactory().getEntityRequest(
|
||||
|
@ -60,7 +70,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
|
|||
.rawExecute();
|
||||
|
||||
String oneLevelResponseBody = StringHelper.asString(oneLevelResponse);
|
||||
assertTrue(oneLevelResponseBody.contains("\"@odata.context\":\"../$metadata#ESTwoPrim/$entity\""));
|
||||
assertTrue(oneLevelResponseBody.contains("\"../$metadata#ESTwoPrim/$entity\""));
|
||||
|
||||
// two navigation
|
||||
final InputStream twoLevelResponse = client.getRetrieveRequestFactory().getEntityRequest(
|
||||
|
@ -71,7 +81,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
|
|||
.rawExecute();
|
||||
|
||||
String twoLevelResponseBody = StringHelper.asString(twoLevelResponse);
|
||||
assertTrue(twoLevelResponseBody.contains("\"@odata.context\":\"../../$metadata#ESTwoPrim/$entity\""));
|
||||
assertTrue(twoLevelResponseBody.contains("\"../../$metadata#ESTwoPrim/$entity\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -166,7 +176,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
|
|||
final ClientProperty property = response.getBody();
|
||||
assertNotNull(property);
|
||||
assertNotNull(property.getPrimitiveValue());
|
||||
assertEquals(1, property.getPrimitiveValue().toValue());
|
||||
assertShortOrInt(1, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class NavigationXmlITCase extends NavigationITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class OrderBySystemQueryOptionXmlITCase extends OrderBySystemQueryITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -72,7 +72,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
|||
|
||||
ODataRetrieveResponse<ClientProperty> response = request.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
assertThat(response.getContentType(), containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
|
||||
assertContentType(response.getContentType());
|
||||
|
||||
final ClientProperty property = response.getBody();
|
||||
assertNotNull(property);
|
||||
|
@ -89,9 +89,19 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
|||
.appendPropertySegment("PropertyString")
|
||||
.build());
|
||||
ODataRetrieveResponse<ClientProperty> response = request.execute();
|
||||
String actualResult = IOUtils.toString(response.getRawResponse(), "UTF-8");
|
||||
assertTrue(actualResult.startsWith("{\"@odata.context\":\"$metadata#ESTwoPrim(32766)/PropertyString\","));
|
||||
assertTrue(actualResult.endsWith("\"value\":\"Test String1\"}"));
|
||||
|
||||
if (isJson()) {
|
||||
String actualResult = IOUtils.toString(response.getRawResponse(), "UTF-8");
|
||||
assertTrue(actualResult.startsWith("{\"@odata.context\":\"$metadata#ESTwoPrim(32766)/PropertyString\","));
|
||||
assertTrue(actualResult.endsWith("\"value\":\"Test String1\"}"));
|
||||
} else {
|
||||
ClientProperty property = response.getBody();
|
||||
assertEquals("Test String1", property.getPrimitiveValue().toValue());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isJson() {
|
||||
return getClient().getConfiguration().getDefaultPubFormat().equals(ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -141,6 +151,10 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
|||
assertTrue(property.getCollectionValue().isEmpty());
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readComplexProperty() throws Exception {
|
||||
final ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
|
||||
|
@ -151,7 +165,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
|||
.build());
|
||||
ODataRetrieveResponse<ClientProperty> response = request.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
assertThat(response.getContentType(), containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
|
||||
assertContentType(response.getContentType());
|
||||
|
||||
final ClientProperty property = response.getBody();
|
||||
assertNotNull(property);
|
||||
|
@ -168,9 +182,16 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
|||
.appendPropertySegment("PropertyComp")
|
||||
.build());
|
||||
ODataRetrieveResponse<ClientProperty> response = request.execute();
|
||||
String actualResult = IOUtils.toString(response.getRawResponse(), "UTF-8");
|
||||
assertTrue(actualResult.startsWith("{\"@odata.context\":\"$metadata#ESMixPrimCollComp(7)/PropertyComp\","));
|
||||
assertTrue(actualResult.endsWith("\"PropertyInt16\":222,\"PropertyString\":\"TEST B\"}"));
|
||||
|
||||
if (isJson()) {
|
||||
String actualResult = IOUtils.toString(response.getRawResponse(), "UTF-8");
|
||||
assertTrue(actualResult.startsWith("{\"@odata.context\":\"$metadata#ESMixPrimCollComp(7)/PropertyComp\","));
|
||||
assertTrue(actualResult.endsWith("\"PropertyInt16\":222,\"PropertyString\":\"TEST B\"}"));
|
||||
} else {
|
||||
ClientProperty property = response.getBody();
|
||||
assertEquals((short)222, property.getComplexValue().get("PropertyInt16").getValue().asPrimitive().toValue());
|
||||
assertEquals("TEST B", property.getComplexValue().get("PropertyString").getValue().asPrimitive().toValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -232,7 +253,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
|||
|
||||
final ODataPropertyUpdateResponse response = request.execute();
|
||||
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
|
||||
assertThat(response.getContentType(), containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
|
||||
assertContentType(response.getContentType());
|
||||
|
||||
final ClientProperty property = response.getBody();
|
||||
assertNotNull(property);
|
||||
|
@ -263,7 +284,11 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
|||
assertNotNull(property.getComplexValue());
|
||||
final ClientComplexValue value = property.getComplexValue();
|
||||
assertEquals("Test String42", value.get("PropertyString").getPrimitiveValue().toValue());
|
||||
assertEquals(222, value.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
if(isJson()) {
|
||||
assertEquals(222, value.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
} else {
|
||||
assertEquals((short)222, value.get("PropertyInt16").getPrimitiveValue().toValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class PrimitiveComplexXmlITCase extends PrimitiveComplexITCase {
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
try {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
} catch(AssertionError t) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_XML.toContentTypeString()));
|
||||
}
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.apache.olingo.client.api.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
||||
public class SystemQueryOptionXmlITCase extends SystemQueryOptionITCase {
|
||||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_ATOM_XML);
|
||||
return odata;
|
||||
}
|
||||
|
||||
protected void assertContentType(String content) {
|
||||
assertThat(content, containsString(ContentType.APPLICATION_ATOM_XML.toContentTypeString()));
|
||||
}
|
||||
|
||||
protected EdmEnabledODataClient getClient(String serviceURI) {
|
||||
return ODataClientFactory.getEdmEnabledClient(serviceURI, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
}
|
|
@ -85,7 +85,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
|||
testAuthServiceRootURL = "http://localhost:9080/stub/DefaultService.svc/V40/Static.svc";
|
||||
testOAuth2ServiceRootURL = "http://localhost:9080/stub/StaticService/V40/OAuth2.svc";
|
||||
|
||||
edmClient = ODataClientFactory.getEdmEnabledClient(testStaticServiceRootURL);
|
||||
edmClient = ODataClientFactory.getEdmEnabledClient(testStaticServiceRootURL, ContentType.JSON);
|
||||
|
||||
edmClient.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
|
||||
client.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.apache.olingo.client.api.domain.ClientLink;
|
|||
import org.apache.olingo.client.api.domain.ClientProperty;
|
||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AsyncTestITCase extends AbstractTestITCase {
|
||||
|
@ -119,11 +120,13 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
|||
assertTrue(found);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void withInlineEntryAsAtom() {
|
||||
withInlineEntry(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void withInlineEntryAsJSON() {
|
||||
// this needs to be full, otherwise there is no mean to recognize links
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.olingo.client.api.uri.URIBuilder;
|
|||
import org.apache.olingo.commons.api.data.ResWrap;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -112,6 +113,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void withInlineEntityFromAtom() {
|
||||
withInlineEntity(client, ContentType.APPLICATION_ATOM_XML);
|
||||
|
@ -155,6 +157,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void withInlineEntitySetFromAtom() {
|
||||
withInlineEntitySet(client, ContentType.APPLICATION_ATOM_XML);
|
||||
|
|
|
@ -88,7 +88,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void readAsJSON() throws IOException {
|
||||
read(ODataClientFactory.getEdmEnabledClient(testDemoServiceRootURL), ContentType.JSON);
|
||||
read(ODataClientFactory.getEdmEnabledClient(testDemoServiceRootURL, ContentType.JSON), ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -68,7 +68,7 @@ public class OAuth2TestITCase extends AbstractTestITCase {
|
|||
|
||||
protected EdmEnabledODataClient getEdmClient() {
|
||||
if (_edmClient == null) {
|
||||
_edmClient = ODataClientFactory.getEdmEnabledClient(testOAuth2ServiceRootURL);
|
||||
_edmClient = ODataClientFactory.getEdmEnabledClient(testOAuth2ServiceRootURL, ContentType.JSON);
|
||||
_edmClient.getConfiguration().setHttpClientFactory(
|
||||
new CXFOAuth2HttpClientFactory(OAUTH2_GRANT_SERVICE_URI, OAUTH2_TOKEN_SERVICE_URI));
|
||||
}
|
||||
|
|
|
@ -30,18 +30,27 @@ public final class ODataClientFactory {
|
|||
}
|
||||
|
||||
public static EdmEnabledODataClient getEdmEnabledClient(final String serviceRoot) {
|
||||
return getEdmEnabledClient(serviceRoot, null, null);
|
||||
return getEdmEnabledClient(serviceRoot, null, null, ContentType.JSON);
|
||||
}
|
||||
|
||||
public static EdmEnabledODataClient getEdmEnabledClient(final String serviceRoot, ContentType contentType) {
|
||||
return getEdmEnabledClient(serviceRoot, null, null, contentType);
|
||||
}
|
||||
|
||||
public static EdmEnabledODataClient getEdmEnabledClient(
|
||||
final String serviceRoot, final Edm edm, final String metadataETag) {
|
||||
|
||||
final EdmEnabledODataClient instance =
|
||||
new EdmEnabledODataClientImpl(serviceRoot, edm, metadataETag);
|
||||
instance.getConfiguration().setDefaultPubFormat(ContentType.JSON);
|
||||
return instance;
|
||||
return getEdmEnabledClient(serviceRoot, edm, metadataETag, ContentType.JSON);
|
||||
}
|
||||
|
||||
|
||||
public static EdmEnabledODataClient getEdmEnabledClient(
|
||||
final String serviceRoot, final Edm edm, final String metadataETag, ContentType contentType) {
|
||||
|
||||
final EdmEnabledODataClient instance =
|
||||
new EdmEnabledODataClientImpl(serviceRoot, edm, metadataETag);
|
||||
instance.getConfiguration().setDefaultPubFormat(contentType);
|
||||
return instance;
|
||||
}
|
||||
private ODataClientFactory() {
|
||||
// empty constructory for static utility class
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ abstract class AbstractAtomDealer {
|
|||
|
||||
protected final String namespaceMetadata;
|
||||
protected final String namespaceData;
|
||||
|
||||
protected final String namespaceAtom;
|
||||
|
||||
protected final QName etagQName;
|
||||
protected final QName metadataEtagQName;
|
||||
protected final QName inlineQName;
|
||||
|
@ -59,6 +60,7 @@ abstract class AbstractAtomDealer {
|
|||
public AbstractAtomDealer() {
|
||||
namespaceMetadata = Constants.NS_METADATA;
|
||||
namespaceData = Constants.NS_DATASERVICES;
|
||||
namespaceAtom = Constants.NS_ATOM;
|
||||
|
||||
etagQName = new QName(namespaceMetadata, Constants.ATOM_ATTR_ETAG);
|
||||
metadataEtagQName = new QName(namespaceMetadata, Constants.ATOM_ATTR_METADATAETAG);
|
||||
|
|
|
@ -20,8 +20,10 @@ package org.apache.olingo.client.core.serialization;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -61,6 +63,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
|||
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
||||
|
||||
import com.fasterxml.aalto.stax.InputFactoryImpl;
|
||||
|
||||
|
@ -95,12 +98,17 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
|
|||
|
||||
if (event.isCharacters() && !event.asCharacters().isWhiteSpace()
|
||||
&& (typeInfo == null || !typeInfo.getPrimitiveTypeKind().isGeospatial())) {
|
||||
|
||||
final String stringValue = event.asCharacters().getData();
|
||||
value = typeInfo == null ? stringValue : // TODO: add facets
|
||||
((EdmPrimitiveType) typeInfo.getType()).valueOfString(stringValue, true, null,
|
||||
if (typeInfo == null) {
|
||||
value = stringValue;
|
||||
} else {
|
||||
final EdmPrimitiveType primitiveType = (EdmPrimitiveType) typeInfo.getType();
|
||||
final Class<?> returnType = primitiveType.getDefaultType().isAssignableFrom(Calendar.class)
|
||||
? Timestamp.class : primitiveType.getDefaultType();
|
||||
value = ((EdmPrimitiveType) typeInfo.getType()).valueOfString(stringValue, true, null,
|
||||
Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, true,
|
||||
((EdmPrimitiveType) typeInfo.getType()).getDefaultType());
|
||||
returnType);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
|
@ -634,11 +642,9 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
|
|||
entity.setMediaETag(mediaETag.getValue());
|
||||
}
|
||||
} else if (link.getRel().startsWith(Constants.NS_NAVIGATION_LINK_REL)) {
|
||||
|
||||
entity.getNavigationLinks().add(link);
|
||||
inline(reader, event.asStartElement(), link);
|
||||
} else if (link.getRel().startsWith(Constants.NS_ASSOCIATION_LINK_REL)) {
|
||||
|
||||
entity.getAssociationLinks().add(link);
|
||||
} else if (link.getRel().startsWith(Constants.NS_MEDIA_EDIT_LINK_REL)) {
|
||||
|
||||
|
|
|
@ -20,8 +20,11 @@ package org.apache.olingo.client.core.serialization;
|
|||
|
||||
import java.io.Writer;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
|
@ -83,7 +86,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
private void value(final XMLStreamWriter writer,
|
||||
final ValueType valueType, final EdmPrimitiveTypeKind kind, final Object value)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
if (value == null) {
|
||||
if (value == null || (valueType == ValueType.COMPLEX && ((ComplexValue)value).getValue().isEmpty())) {
|
||||
writer.writeAttribute(Constants.PREFIX_METADATA, namespaceMetadata,
|
||||
Constants.ATTR_NULL, Boolean.TRUE.toString());
|
||||
return;
|
||||
|
@ -140,7 +143,11 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
property.getValue());
|
||||
if (!property.isNull() && property.isComplex() && !property.isCollection()) {
|
||||
links(writer, property.asComplex().getAssociationLinks());
|
||||
links(writer, property.asComplex().getNavigationLinks());
|
||||
if (serverMode) {
|
||||
links(writer, property.asComplex().getNavigationLinks());
|
||||
} else {
|
||||
writeNavigationLinks(writer, property.asComplex().getNavigationLinks());
|
||||
}
|
||||
}
|
||||
|
||||
writer.writeEndElement();
|
||||
|
@ -158,7 +165,6 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
private void startDocument(final XMLStreamWriter writer, final String rootElement) throws XMLStreamException {
|
||||
writer.writeStartDocument();
|
||||
writer.setDefaultNamespace(Constants.NS_ATOM);
|
||||
|
||||
writer.writeStartElement(rootElement);
|
||||
|
||||
namespaces(writer);
|
||||
|
@ -175,49 +181,147 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
writer.writeEndDocument();
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
private boolean isEntitySetNavigation(final Link link) {
|
||||
return Constants.ENTITY_SET_NAVIGATION_LINK_TYPE.equals(link.getType());
|
||||
}
|
||||
|
||||
private void writeNavigationLinks(final XMLStreamWriter writer, final List<Link> links)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
final Map<String, List<String>> entitySetLinks = new HashMap<String, List<String>>();
|
||||
|
||||
for (Link link : links) {
|
||||
|
||||
if (link.getInlineEntity() != null || link.getInlineEntitySet() != null) {
|
||||
writeLink(writer, link, new ExtraContent() {
|
||||
@Override
|
||||
public void write(XMLStreamWriter writer, Link link) throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE, namespaceMetadata);
|
||||
if (link.getInlineEntity() != null) {
|
||||
writer.writeStartElement(namespaceAtom, Constants.ATOM_ELEM_ENTRY);
|
||||
entity(writer, link.getInlineEntity());
|
||||
writer.writeEndElement();
|
||||
}
|
||||
if (link.getInlineEntitySet() != null) {
|
||||
writer.writeStartElement(namespaceAtom, Constants.ATOM_ELEM_FEED);
|
||||
entitySet(writer, link.getInlineEntitySet());
|
||||
writer.writeEndElement();
|
||||
}
|
||||
writer.writeEndElement(); // inline
|
||||
}
|
||||
});
|
||||
|
||||
} else if (link.getBindingLink() != null) {
|
||||
writeLink(writer, link, new ExtraContent() {
|
||||
@Override
|
||||
public void write(XMLStreamWriter writer, Link link) throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
writer.writeAttribute(Constants.ATTR_HREF, link.getBindingLink());
|
||||
}
|
||||
});
|
||||
} else if (link.getBindingLinks() != null && !link.getBindingLinks().isEmpty()) {
|
||||
writeLink(writer, link, new ExtraContent() {
|
||||
@Override
|
||||
public void write(XMLStreamWriter writer, Link link) throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE, namespaceMetadata);
|
||||
writer.writeStartElement(namespaceAtom, Constants.ATOM_ELEM_FEED);
|
||||
for (String binding:link.getBindingLinks()) {
|
||||
Entity entity = new Entity();
|
||||
entity.setId(URI.create(binding));
|
||||
inlineEntityRef(writer, entity);
|
||||
}
|
||||
writer.writeEndElement(); //feed
|
||||
writer.writeEndElement(); //inline
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (isEntitySetNavigation(link)) {
|
||||
final List<String> uris;
|
||||
if (entitySetLinks.containsKey(link.getTitle())) {
|
||||
uris = entitySetLinks.get(link.getTitle());
|
||||
} else {
|
||||
uris = new ArrayList<String>();
|
||||
entitySetLinks.put(link.getTitle(), uris);
|
||||
}
|
||||
if (StringUtils.isNotBlank(link.getHref())) {
|
||||
uris.add(link.getHref());
|
||||
}
|
||||
} else {
|
||||
writeLink(writer, link, new ExtraContent() {
|
||||
@Override
|
||||
public void write(XMLStreamWriter writer, Link link)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String title : entitySetLinks.keySet()) {
|
||||
final List<String>entitySetLink = entitySetLinks.get(title);
|
||||
if (!entitySetLink.isEmpty()) {
|
||||
Link link = new Link();
|
||||
link.setTitle(title);
|
||||
link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
|
||||
link.setRel(Constants.NS_NAVIGATION_LINK_REL+title);
|
||||
|
||||
writeLink(writer, link, new ExtraContent() {
|
||||
@Override
|
||||
public void write(XMLStreamWriter writer, Link link) throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE, namespaceMetadata);
|
||||
writer.writeStartElement(namespaceAtom, Constants.ATOM_ELEM_FEED);
|
||||
for (String binding:entitySetLink) {
|
||||
Entity entity = new Entity();
|
||||
entity.setId(URI.create(binding));
|
||||
inlineEntityRef(writer, entity);
|
||||
}
|
||||
writer.writeEndElement();
|
||||
writer.writeEndElement();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void links(final XMLStreamWriter writer, final List<Link> links)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
for (Link link : links) {
|
||||
writer.writeStartElement(Constants.ATOM_ELEM_LINK);
|
||||
|
||||
if (StringUtils.isNotBlank(link.getRel())) {
|
||||
writer.writeAttribute(Constants.ATTR_REL, link.getRel());
|
||||
}
|
||||
if (StringUtils.isNotBlank(link.getTitle())) {
|
||||
writer.writeAttribute(Constants.ATTR_TITLE, link.getTitle());
|
||||
}
|
||||
if (StringUtils.isNotBlank(link.getHref())) {
|
||||
writer.writeAttribute(Constants.ATTR_HREF, link.getHref());
|
||||
}
|
||||
if (StringUtils.isNotBlank(link.getType())) {
|
||||
writer.writeAttribute(Constants.ATTR_TYPE, link.getType());
|
||||
}
|
||||
|
||||
if (link.getInlineEntity() != null || link.getInlineEntitySet() != null) {
|
||||
writer.writeStartElement(Constants.PREFIX_METADATA, Constants.ATOM_ELEM_INLINE, namespaceMetadata);
|
||||
|
||||
if (link.getInlineEntity() != null) {
|
||||
writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
|
||||
entity(writer, link.getInlineEntity());
|
||||
writer.writeEndElement();
|
||||
writeLink(writer, link, new ExtraContent() {
|
||||
@Override
|
||||
public void write(XMLStreamWriter writer, Link link)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
}
|
||||
if (link.getInlineEntitySet() != null) {
|
||||
writer.writeStartElement(Constants.ATOM_ELEM_FEED);
|
||||
entitySet(writer, link.getInlineEntitySet());
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
||||
for (Annotation annotation : link.getAnnotations()) {
|
||||
annotation(writer, annotation, null);
|
||||
}
|
||||
|
||||
writer.writeEndElement();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
interface ExtraContent {
|
||||
void write(final XMLStreamWriter writer, final Link link)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException;
|
||||
}
|
||||
|
||||
private void writeLink(final XMLStreamWriter writer, final Link link, final ExtraContent content)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException {
|
||||
writer.writeStartElement(Constants.ATOM_ELEM_LINK);
|
||||
|
||||
if (StringUtils.isNotBlank(link.getRel())) {
|
||||
writer.writeAttribute(Constants.ATTR_REL, link.getRel());
|
||||
}
|
||||
if (StringUtils.isNotBlank(link.getTitle())) {
|
||||
writer.writeAttribute(Constants.ATTR_TITLE, link.getTitle());
|
||||
}
|
||||
if (StringUtils.isNotBlank(link.getHref())) {
|
||||
writer.writeAttribute(Constants.ATTR_HREF, link.getHref());
|
||||
}
|
||||
if (StringUtils.isNotBlank(link.getType())) {
|
||||
writer.writeAttribute(Constants.ATTR_TYPE, link.getType());
|
||||
}
|
||||
|
||||
content.write(writer, link);
|
||||
|
||||
for (Annotation annotation : link.getAnnotations()) {
|
||||
annotation(writer, annotation, null);
|
||||
}
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
||||
private void common(final XMLStreamWriter writer, final AbstractODataObject object) throws XMLStreamException {
|
||||
if (StringUtils.isNotBlank(object.getTitle())) {
|
||||
|
@ -298,7 +402,12 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
}
|
||||
|
||||
links(writer, entity.getAssociationLinks());
|
||||
links(writer, entity.getNavigationLinks());
|
||||
if (serverMode) {
|
||||
links(writer, entity.getNavigationLinks());
|
||||
} else {
|
||||
writeNavigationLinks(writer, entity.getNavigationLinks());
|
||||
writeNavigationLinks(writer, entity.getNavigationBindings());
|
||||
}
|
||||
links(writer, entity.getMediaEditLinks());
|
||||
|
||||
if (serverMode) {
|
||||
|
@ -336,15 +445,22 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
}
|
||||
}
|
||||
|
||||
private void inlineEntityRef(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException {
|
||||
writer.writeStartElement(namespaceMetadata, Constants.ATOM_ELEM_ENTRY_REF);
|
||||
writer.writeAttribute(Constants.ATOM_ATTR_ID, entity.getId().toASCIIString());
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
||||
private void entityRef(final XMLStreamWriter writer, final Entity entity) throws XMLStreamException {
|
||||
writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
|
||||
writer.writeNamespace(StringUtils.EMPTY, namespaceMetadata);
|
||||
writer.writeDefaultNamespace(namespaceMetadata);
|
||||
writer.writeAttribute(Constants.ATOM_ATTR_ID, entity.getId().toASCIIString());
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
||||
private void entityRef(final XMLStreamWriter writer, final ResWrap<Entity> container) throws XMLStreamException {
|
||||
writer.writeStartElement(Constants.ATOM_ELEM_ENTRY_REF);
|
||||
writer.writeNamespace(StringUtils.EMPTY, namespaceMetadata);
|
||||
writer.writeDefaultNamespace(namespaceMetadata);
|
||||
addContextInfo(writer, container);
|
||||
writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().getId().toASCIIString());
|
||||
}
|
||||
|
@ -356,15 +472,11 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
if (entity.getType() == null && entity.getProperties().isEmpty()) {
|
||||
writer.writeStartDocument();
|
||||
writer.setDefaultNamespace(namespaceMetadata);
|
||||
|
||||
entityRef(writer, entity);
|
||||
} else {
|
||||
startDocument(writer, Constants.ATOM_ELEM_ENTRY);
|
||||
|
||||
entity(writer, entity);
|
||||
}
|
||||
|
||||
writer.writeEndElement();
|
||||
writer.writeEndDocument();
|
||||
writer.flush();
|
||||
}
|
||||
|
@ -416,7 +528,6 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
for (Entity entity : entitySet.getEntities()) {
|
||||
if (entity.getType() == null && entity.getProperties().isEmpty()) {
|
||||
entityRef(writer, entity);
|
||||
writer.writeEndElement();
|
||||
} else {
|
||||
writer.writeStartElement(Constants.ATOM_ELEM_ENTRY);
|
||||
entity(writer, entity);
|
||||
|
@ -512,9 +623,10 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize
|
|||
|
||||
writer.writeStartDocument();
|
||||
|
||||
writer.writeStartElement(Constants.ATTR_METADATA, Constants.ATTR_REF);
|
||||
writer.writeStartElement(Constants.ATTR_METADATA, Constants.ATTR_REF, Constants.NS_METADATA);
|
||||
writer.writeNamespace(Constants.ATTR_METADATA, Constants.NS_METADATA);
|
||||
writer.writeAttribute(Constants.ATTR_METADATA, Constants.CONTEXT, container.getContextURL().toASCIIString());
|
||||
writer.writeAttribute(Constants.ATTR_METADATA, Constants.NS_METADATA, Constants.CONTEXT,
|
||||
container.getContextURL().toASCIIString());
|
||||
writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().toASCIIString());
|
||||
writer.writeEndElement();
|
||||
|
||||
|
|
|
@ -456,7 +456,7 @@ public class ODataBinderImpl implements ODataBinder {
|
|||
odataLinked.addLink(createODataInlineEntity(inlineEntity,
|
||||
URIUtils.getURI(base, href), title, metadataETag));
|
||||
} else {
|
||||
odataLinked.addLink(createODataInlineEntitySet(inlineEntitySet,
|
||||
odataLinked.addLink(createODataInlineEntitySet(inlineEntitySet, href == null?null:
|
||||
URIUtils.getURI(base, href), title, metadataETag));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ public class JSONTest extends AbstractTest {
|
|||
final StringWriter writer = new StringWriter();
|
||||
getClient().getSerializer(contentType).write(writer, getClient().getDeserializer(contentType).toEntity(
|
||||
getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload());
|
||||
|
||||
System.out.println(writer.toString());
|
||||
assertSimilar(filename + "." + getSuffix(contentType), writer.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,9 @@
|
|||
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Customer" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
|
||||
<link rel="edit" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)"/>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)/Parent"/>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)/Orders"/>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders"
|
||||
type="application/atom+xml;type=feed" title="Orders">
|
||||
<m:inline><feed><m:ref id="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)/Orders"/></feed></m:inline></link>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)/Company"/>
|
||||
<title/>
|
||||
<updated>2014-03-31T09:35:14Z</updated>
|
||||
|
@ -76,7 +78,10 @@
|
|||
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Customer" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
|
||||
<link rel="edit" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=2)"/>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=2)/Parent"/>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=2)/Orders"/>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed"
|
||||
title="Orders">
|
||||
<m:inline><feed><m:ref id="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=2)/Orders"/></feed></m:inline>
|
||||
</link>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=2)/Company"/>
|
||||
<title/>
|
||||
<updated>2014-03-31T09:35:14Z</updated>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<id>http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)</id>
|
||||
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
|
||||
<link rel="edit" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)" />
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Details" type="application/atom+xml;type=feed" title="Details" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Details" />
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Details" type="application/atom+xml;type=feed" title="Details"><m:inline><feed><ref xmlns="http://docs.oasis-open.org/odata/ns/metadata" id="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Products(5)/Details"/></feed></m:inline></link>
|
||||
<title />
|
||||
<updated>2014-03-28T11:24:49Z</updated>
|
||||
<author>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Customer" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
|
||||
<link rel="edit" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer" />
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Parent" />
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Orders" />
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed" title="Orders"><m:inline><feed><ref xmlns="http://docs.oasis-open.org/odata/ns/metadata" id="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Orders"/></feed></m:inline></link>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/VipCustomer/Company" />
|
||||
<title />
|
||||
<updated>2014-03-28T13:03:32Z</updated>
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Customer" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
|
||||
<link rel="edit" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)"/>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)/Parent"/>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)/Orders">
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders"
|
||||
type="application/atom+xml;type=feed" title="Orders">
|
||||
<m:inline><feed><m:ref id="http://odatae2etest.azurewebsites.net/javatest/DefaultService/Customers(PersonID=1)/Orders"/></feed></m:inline>
|
||||
<m:annotation term="com.contoso.display.style" m:type="#com.contoso.display.styleType">
|
||||
<d:order m:type="Int32">2</d:order>
|
||||
</m:annotation>
|
||||
|
|
|
@ -33,7 +33,8 @@ under the License.
|
|||
<link rel="edit" title="Customer" href="Customers('ALFKI')"/>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders"
|
||||
type="application/atom+xml;type=feed"
|
||||
title="Orders" href="Customers('ALFKI')/Orders"/>
|
||||
title="Orders">
|
||||
<m:inline><feed><m:ref id="Customers('ALFKI')/Orders"/></feed></m:inline> </link>
|
||||
<link rel="http://docs.oasis-open.org/odata/ns/related/Supplier"
|
||||
type="application/atom+xml;type=entry"
|
||||
title="Supplier" href="Customers('ALFKI')/Supplier"/>
|
||||
|
|
|
@ -31,7 +31,8 @@ public class EntityCollectionSerializerOptions {
|
|||
private ExpandOption expand;
|
||||
private SelectOption select;
|
||||
private boolean onlyReferences;
|
||||
|
||||
private String id;
|
||||
|
||||
/** Gets the {@link ContextURL}. */
|
||||
public ContextURL getContextURL() {
|
||||
return contextURL;
|
||||
|
@ -56,6 +57,11 @@ public class EntityCollectionSerializerOptions {
|
|||
public boolean onlyReferences() {
|
||||
return onlyReferences;
|
||||
}
|
||||
|
||||
/** Gets the id of the entity collection */
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/** Initializes the options builder. */
|
||||
public static Builder with() {
|
||||
|
@ -101,6 +107,12 @@ public class EntityCollectionSerializerOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/** Sets id of the collection */
|
||||
public Builder setId(final String id) {
|
||||
options.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Builds the OData serializer options. */
|
||||
public EntityCollectionSerializerOptions build() {
|
||||
return options;
|
||||
|
|
|
@ -152,7 +152,8 @@ public abstract class ServiceRequest {
|
|||
return (T) EntityCollectionSerializerOptions.with()
|
||||
.contextURL(isODataMetadataNone(getResponseContentType()) ? null : contextUrl)
|
||||
.count(uriInfo.getCountOption()).expand(uriInfo.getExpandOption())
|
||||
.select(uriInfo.getSelectOption()).setWriteOnlyReferences(references).build();
|
||||
.select(uriInfo.getSelectOption()).setWriteOnlyReferences(references)
|
||||
.setId(getODataRequest().getRawBaseUri()+getODataRequest().getRawODataPath()).build();
|
||||
} else if (serilizerOptions.isAssignableFrom(ComplexSerializerOptions.class)) {
|
||||
return (T) ComplexSerializerOptions.with().contextURL(contextUrl)
|
||||
.expand(this.uriInfo.getExpandOption()).select(this.uriInfo.getSelectOption()).build();
|
||||
|
|
|
@ -53,7 +53,9 @@ public class ContentNegotiator {
|
|||
return Arrays.asList(
|
||||
ContentType.JSON,
|
||||
ContentType.JSON_NO_METADATA,
|
||||
ContentType.APPLICATION_JSON);
|
||||
ContentType.APPLICATION_JSON,
|
||||
ContentType.APPLICATION_ATOM_XML,
|
||||
ContentType.APPLICATION_XML);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,11 +44,12 @@ import org.apache.olingo.server.api.uri.UriHelper;
|
|||
import org.apache.olingo.server.core.debug.DebugResponseHelperImpl;
|
||||
import org.apache.olingo.server.core.deserializer.FixedFormatDeserializerImpl;
|
||||
import org.apache.olingo.server.core.deserializer.json.ODataJsonDeserializer;
|
||||
import org.apache.olingo.server.core.deserializer.xml.ODataXmlDeserializer;
|
||||
import org.apache.olingo.server.core.etag.ETagHelperImpl;
|
||||
import org.apache.olingo.server.core.prefer.PreferencesImpl;
|
||||
import org.apache.olingo.server.core.serializer.FixedFormatSerializerImpl;
|
||||
import org.apache.olingo.server.core.serializer.json.ODataJsonSerializer;
|
||||
import org.apache.olingo.server.core.serializer.xml.ODataXmlSerializerImpl;
|
||||
import org.apache.olingo.server.core.serializer.xml.ODataXmlSerializer;
|
||||
import org.apache.olingo.server.core.uri.UriHelperImpl;
|
||||
|
||||
public class ODataImpl extends OData {
|
||||
|
@ -64,8 +65,9 @@ public class ODataImpl extends OData {
|
|||
|| ContentType.VALUE_ODATA_METADATA_NONE.equals(metadata)) {
|
||||
serializer = new ODataJsonSerializer(contentType);
|
||||
}
|
||||
} else if (contentType.isCompatible(ContentType.APPLICATION_XML)) {
|
||||
serializer = new ODataXmlSerializerImpl();
|
||||
} else if (contentType.isCompatible(ContentType.APPLICATION_XML)
|
||||
|| contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
|
||||
serializer = new ODataXmlSerializer();
|
||||
}
|
||||
|
||||
if (serializer == null) {
|
||||
|
@ -114,15 +116,13 @@ public class ODataImpl extends OData {
|
|||
|
||||
if (contentType.isCompatible(ContentType.JSON)) {
|
||||
deserializer = new ODataJsonDeserializer(contentType);
|
||||
// } else if(contentType.isCompatible(ContentType.APPLICATION_XML))
|
||||
// We do not support XML deserialization right now so this must lead
|
||||
// to an error.
|
||||
// {
|
||||
} else if (contentType.isCompatible(ContentType.APPLICATION_XML)
|
||||
|| contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
|
||||
deserializer = new ODataXmlDeserializer();
|
||||
} else {
|
||||
throw new DeserializerException("Unsupported format: " + contentType.toContentTypeString(),
|
||||
DeserializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString());
|
||||
}
|
||||
|
||||
return deserializer;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,702 @@
|
|||
/*
|
||||
* 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.server.core.deserializer.xml;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.data.AbstractODataObject;
|
||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||
import org.apache.olingo.commons.api.data.Link;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.data.Valuable;
|
||||
import org.apache.olingo.commons.api.data.ValueType;
|
||||
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.EdmEnumType;
|
||||
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.EdmProperty;
|
||||
import org.apache.olingo.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.AbstractGeospatialType;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.SingletonPrimitiveType;
|
||||
import org.apache.olingo.server.api.deserializer.DeserializerException;
|
||||
import org.apache.olingo.server.api.deserializer.DeserializerResult;
|
||||
import org.apache.olingo.server.api.deserializer.ODataDeserializer;
|
||||
import org.apache.olingo.server.core.deserializer.DeserializerResultImpl;
|
||||
|
||||
import com.fasterxml.aalto.stax.InputFactoryImpl;
|
||||
|
||||
public class ODataXmlDeserializer implements ODataDeserializer {
|
||||
|
||||
protected static final XMLInputFactory FACTORY = new InputFactoryImpl();
|
||||
private static final String ATOM = "a";
|
||||
private static final String NS_ATOM = "http://www.w3.org/2005/Atom";
|
||||
protected QName REF_ELEMENT = new QName("http://docs.oasis-open.org/odata/ns/metadata", "ref");
|
||||
protected QName FEED_ELEMENT = new QName("http://www.w3.org/2005/Atom", "feed");
|
||||
protected QName ID_ATTR = new QName(NS_ATOM, ATOM);
|
||||
|
||||
protected final QName propertiesQName = new QName(Constants.NS_METADATA, Constants.PROPERTIES);
|
||||
protected final QName propertyValueQName = new QName(Constants.NS_METADATA, Constants.VALUE);
|
||||
protected final QName contextQName = new QName(Constants.NS_METADATA, Constants.CONTEXT);
|
||||
protected final QName nullQName = new QName(Constants.NS_METADATA, Constants.ATTR_NULL);
|
||||
protected final QName inlineQName = new QName(Constants.NS_METADATA, Constants.ATOM_ELEM_INLINE);
|
||||
protected final QName entryRefQName = new QName(Constants.NS_METADATA, Constants.ATOM_ELEM_ENTRY_REF);
|
||||
protected final QName etagQName = new QName(Constants.NS_METADATA, Constants.ATOM_ATTR_ETAG);
|
||||
protected final QName countQName = new QName(Constants.NS_METADATA, Constants.ATOM_ELEM_COUNT);
|
||||
|
||||
protected void namespaces(final XMLStreamWriter writer) throws XMLStreamException {
|
||||
writer.writeNamespace(StringUtils.EMPTY, Constants.NS_ATOM);
|
||||
writer.writeNamespace(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
|
||||
writer.writeNamespace(Constants.PREFIX_METADATA, Constants.NS_METADATA);
|
||||
writer.writeNamespace(Constants.PREFIX_DATASERVICES, Constants.NS_DATASERVICES);
|
||||
writer.writeNamespace(Constants.PREFIX_GML, Constants.NS_GML);
|
||||
writer.writeNamespace(Constants.PREFIX_GEORSS, Constants.NS_GEORSS);
|
||||
}
|
||||
|
||||
protected XMLEventReader getReader(final InputStream input) throws XMLStreamException {
|
||||
return FACTORY.createXMLEventReader(input);
|
||||
}
|
||||
|
||||
private Object primitive(final XMLEventReader reader, final StartElement start,
|
||||
final EdmProperty edmProperty) throws XMLStreamException, EdmPrimitiveTypeException,
|
||||
DeserializerException {
|
||||
|
||||
Object value = null;
|
||||
|
||||
boolean foundEndProperty = false;
|
||||
while (reader.hasNext() && !foundEndProperty) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
|
||||
if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
|
||||
if (edmProperty.getType() instanceof AbstractGeospatialType<?>) {
|
||||
throw new DeserializerException("geo types support not implemented",
|
||||
DeserializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
final String stringValue = event.asCharacters().getData();
|
||||
value = ((EdmPrimitiveType)edmProperty.getType()).valueOfString(stringValue,
|
||||
edmProperty.isNullable(),
|
||||
edmProperty.getMaxLength(),
|
||||
edmProperty.getPrecision(),
|
||||
edmProperty.getScale(),
|
||||
edmProperty.isUnicode(),
|
||||
((EdmPrimitiveType)edmProperty.getType()).getDefaultType());
|
||||
}
|
||||
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndProperty = true;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private Object complex(final XMLEventReader reader, final StartElement start, EdmComplexType edmComplex,
|
||||
boolean validateType)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
|
||||
|
||||
ComplexValue value = new ComplexValue();
|
||||
boolean foundEndProperty = false;
|
||||
while (reader.hasNext() && !foundEndProperty) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
if (event.isStartElement()) {
|
||||
StartElement se = event.asStartElement();
|
||||
value.getValue().add(property(reader, se, (EdmProperty)edmComplex.getProperty(se.getName().getLocalPart())));
|
||||
}
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndProperty = true;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private void collection(final Valuable valuable, final XMLEventReader reader, final StartElement start,
|
||||
final EdmProperty edmProperty) throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
|
||||
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
EdmType edmType = edmProperty.getType();
|
||||
|
||||
boolean foundEndProperty = false;
|
||||
while (reader.hasNext() && !foundEndProperty) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
|
||||
if (event.isStartElement()) {
|
||||
if (edmType instanceof SingletonPrimitiveType) {
|
||||
values.add(primitive(reader, event.asStartElement(), edmProperty));
|
||||
} else if (edmType instanceof EdmComplexType) {
|
||||
values.add(complex(reader, event.asStartElement(), (EdmComplexType)edmType, false));
|
||||
} else if (edmType instanceof EdmEnumType) {
|
||||
values.add(readEnum(reader, event.asStartElement(), edmProperty));
|
||||
} else {
|
||||
// do not add null or empty values
|
||||
}
|
||||
}
|
||||
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndProperty = true;
|
||||
}
|
||||
}
|
||||
valuable.setValue(getValueType(edmType, true), values);
|
||||
}
|
||||
|
||||
private Object readEnum(XMLEventReader reader, StartElement start, EdmProperty edmProperty)
|
||||
throws XMLStreamException {
|
||||
boolean foundEndProperty = false;
|
||||
Object value = null;
|
||||
while (reader.hasNext() && !foundEndProperty) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
|
||||
value = event.asCharacters().getData();
|
||||
}
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndProperty = true;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private Property property(final XMLEventReader reader, final StartElement start, final EdmProperty edmProperty)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
|
||||
|
||||
final Property property = new Property();
|
||||
|
||||
if (propertyValueQName.equals(start.getName())) {
|
||||
// retrieve name from context
|
||||
final Attribute context = start.getAttributeByName(contextQName);
|
||||
if (context != null) {
|
||||
property.setName(StringUtils.substringAfterLast(context.getValue(), "/"));
|
||||
}
|
||||
} else {
|
||||
property.setName(start.getName().getLocalPart());
|
||||
}
|
||||
valuable(property, reader, start, edmProperty);
|
||||
return property;
|
||||
}
|
||||
|
||||
private ValueType getValueType(EdmType edmType, boolean isCollection) {
|
||||
if (edmType instanceof SingletonPrimitiveType) {
|
||||
return isCollection? ValueType.COLLECTION_PRIMITIVE:ValueType.PRIMITIVE;
|
||||
} else if (edmType instanceof EdmComplexType) {
|
||||
return isCollection? ValueType.COLLECTION_COMPLEX:ValueType.COMPLEX;
|
||||
} else if (edmType instanceof EdmEnumType) {
|
||||
return isCollection?ValueType.COLLECTION_ENUM:ValueType.ENUM;
|
||||
} else {
|
||||
return ValueType.PRIMITIVE;
|
||||
}
|
||||
}
|
||||
|
||||
private void valuable(final Valuable valuable, final XMLEventReader reader, final StartElement start,
|
||||
EdmProperty edmProperty) throws XMLStreamException, EdmPrimitiveTypeException,
|
||||
DeserializerException {
|
||||
|
||||
final Attribute nullAttr = start.getAttributeByName(nullQName);
|
||||
if (nullAttr != null) {
|
||||
//found null
|
||||
boolean foundEndProperty = false;
|
||||
while (reader.hasNext() && !foundEndProperty) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndProperty = true;
|
||||
}
|
||||
}
|
||||
valuable.setValue(getValueType(edmProperty.getType(), false), null);
|
||||
return;
|
||||
}
|
||||
|
||||
EdmType edmType = edmProperty.getType();
|
||||
if (edmProperty.isCollection()) {
|
||||
collection(valuable, reader, start, edmProperty);
|
||||
valuable.setType("Collection("+edmType.getFullQualifiedName().getFullQualifiedNameAsString()+")");
|
||||
} else if (edmType instanceof SingletonPrimitiveType) {
|
||||
valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
valuable.setValue(ValueType.PRIMITIVE, primitive(reader, start, edmProperty));
|
||||
} else if (edmType instanceof EdmComplexType) {
|
||||
valuable.setValue(ValueType.COMPLEX, complex(reader, start, (EdmComplexType)edmType, true));
|
||||
valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
} else if (edmType instanceof EdmEnumType) {
|
||||
valuable.setValue(ValueType.ENUM, readEnum(reader, start, edmProperty));
|
||||
valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
} else {
|
||||
// do not add null or empty values
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeserializerResult property(InputStream input, EdmProperty edmProperty)
|
||||
throws DeserializerException {
|
||||
try {
|
||||
final XMLEventReader reader = getReader(input);
|
||||
final StartElement start = skipBeforeFirstStartElement(reader);
|
||||
Property property = property(reader, start, edmProperty);
|
||||
return DeserializerResultImpl.with().property(property)
|
||||
.build();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new DeserializerException(e.getMessage(), e, DeserializerException.MessageKeys.IO_EXCEPTION);
|
||||
} catch (final EdmPrimitiveTypeException e) {
|
||||
throw new DeserializerException(e.getMessage(), e,
|
||||
DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
|
||||
}
|
||||
}
|
||||
|
||||
private StartElement skipBeforeFirstStartElement(final XMLEventReader reader) throws XMLStreamException {
|
||||
StartElement startEvent = null;
|
||||
while (reader.hasNext() && startEvent == null) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
if (event.isStartElement()) {
|
||||
startEvent = event.asStartElement();
|
||||
}
|
||||
}
|
||||
if (startEvent == null) {
|
||||
throw new IllegalArgumentException("Cannot find any XML start element");
|
||||
}
|
||||
|
||||
return startEvent;
|
||||
}
|
||||
|
||||
private void common(final XMLEventReader reader, final StartElement start,
|
||||
final AbstractODataObject object, final String key) throws XMLStreamException {
|
||||
|
||||
boolean foundEndElement = false;
|
||||
while (reader.hasNext() && !foundEndElement) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
|
||||
if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
|
||||
try {
|
||||
object.setCommonProperty(key, event.asCharacters().getData());
|
||||
} catch (ParseException e) {
|
||||
throw new XMLStreamException("While parsing Atom entry or feed common elements", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndElement = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void inline(final XMLEventReader reader, final StartElement start, final Link link,
|
||||
final EdmEntityType edmEntityType) throws XMLStreamException, EdmPrimitiveTypeException,
|
||||
DeserializerException {
|
||||
|
||||
boolean foundEndElement = false;
|
||||
EdmNavigationProperty navigationProperty = edmEntityType.getNavigationProperty(link.getTitle());
|
||||
while (reader.hasNext() && !foundEndElement) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
|
||||
if (event.isStartElement()) {
|
||||
if (inlineQName.equals(event.asStartElement().getName())) {
|
||||
StartElement inline = getStartElement(reader);
|
||||
if (inline != null) {
|
||||
if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(inline.getName())) {
|
||||
if (navigationProperty.isCollection()) {
|
||||
throw new DeserializerException( "Navigation Property "+ link.getTitle() +
|
||||
" must be collection entities",
|
||||
DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE, link.getTitle());
|
||||
}
|
||||
|
||||
link.setInlineEntity(entity(reader, inline, navigationProperty.getType()));
|
||||
}
|
||||
if (Constants.QNAME_ATOM_ELEM_FEED.equals(inline.getName())) {
|
||||
if (!navigationProperty.isCollection()) {
|
||||
throw new DeserializerException("Navigation Property " + link.getTitle() +
|
||||
" must be single entity",
|
||||
DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE, link.getTitle());
|
||||
}
|
||||
link.setInlineEntitySet(entitySet(reader, inline, navigationProperty.getType()));
|
||||
}
|
||||
}
|
||||
} else if (REF_ELEMENT.equals(event.asStartElement().getName())) {
|
||||
if (navigationProperty.isCollection()) {
|
||||
throw new DeserializerException("Binding annotation: " + link.getTitle() +
|
||||
" must be collection of entity refercences",
|
||||
DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE, link.getTitle());
|
||||
}
|
||||
link.setBindingLink(entityRef(reader, event.asStartElement()));
|
||||
link.setType(Constants.ENTITY_BINDING_LINK_TYPE);
|
||||
} else if (Constants.QNAME_ATOM_ELEM_FEED.equals(event.asStartElement().getName())) {
|
||||
if (navigationProperty.isCollection()) {
|
||||
throw new DeserializerException("Binding annotation: " + link.getTitle() +
|
||||
" must be single entity refercences",
|
||||
DeserializerException.MessageKeys.INVALID_ANNOTATION_TYPE, link.getTitle());
|
||||
}
|
||||
link.setBindingLinks(entityRefCollection(reader, event.asStartElement()));
|
||||
link.setType(Constants.ENTITY_COLLECTION_BINDING_LINK_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndElement = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> entityRefCollection(XMLEventReader reader, StartElement start)
|
||||
throws XMLStreamException {
|
||||
boolean foundEndElement = false;
|
||||
ArrayList<String> references = new ArrayList<String>();
|
||||
while (reader.hasNext() && !foundEndElement) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
|
||||
if (event.isStartElement()) {
|
||||
if (REF_ELEMENT.equals(event.asStartElement().getName())) {
|
||||
references.add(entityRef(reader, event.asStartElement()));
|
||||
}
|
||||
}
|
||||
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndElement = true;
|
||||
}
|
||||
}
|
||||
return references;
|
||||
}
|
||||
|
||||
private String entityRef(XMLEventReader reader, StartElement start) throws XMLStreamException {
|
||||
boolean foundEndElement = false;
|
||||
final Attribute entityRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
|
||||
while (reader.hasNext() && !foundEndElement) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndElement = true;
|
||||
}
|
||||
}
|
||||
return entityRefId.getValue();
|
||||
}
|
||||
|
||||
private StartElement getStartElement(final XMLEventReader reader) throws XMLStreamException {
|
||||
while (reader.hasNext()) {
|
||||
final XMLEvent innerEvent = reader.peek();
|
||||
if (innerEvent.isCharacters() && innerEvent.asCharacters().isWhiteSpace()) {
|
||||
reader.nextEvent();
|
||||
} else if (innerEvent.isStartElement()) {
|
||||
return innerEvent.asStartElement();
|
||||
} else if (innerEvent.isEndElement() && inlineQName.equals(innerEvent.asEndElement().getName())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void properties(final XMLEventReader reader, final StartElement start, final Entity entity,
|
||||
final EdmEntityType edmEntityType)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
|
||||
|
||||
boolean foundEndProperties = false;
|
||||
while (reader.hasNext() && !foundEndProperties) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
|
||||
if (event.isStartElement()) {
|
||||
EdmProperty edmProperty = (EdmProperty)edmEntityType
|
||||
.getProperty(event.asStartElement().getName().getLocalPart());
|
||||
entity.getProperties().add(property(reader, event.asStartElement(), edmProperty));
|
||||
}
|
||||
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndProperties = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Entity entityRef(final StartElement start) throws XMLStreamException {
|
||||
final Entity entity = new Entity();
|
||||
|
||||
final Attribute entityRefId = start.getAttributeByName(Constants.QNAME_ATOM_ATTR_ID);
|
||||
if (entityRefId != null) {
|
||||
entity.setId(URI.create(entityRefId.getValue()));
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
private Entity entity(final XMLEventReader reader, final StartElement start, final EdmEntityType edmEntityType)
|
||||
throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
|
||||
Entity entity = null;
|
||||
if (entryRefQName.equals(start.getName())) {
|
||||
entity = entityRef(start);
|
||||
} else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(start.getName())) {
|
||||
entity = new Entity();
|
||||
final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
|
||||
if (xmlBase != null) {
|
||||
entity.setBaseURI(URI.create(xmlBase.getValue()));
|
||||
}
|
||||
|
||||
final Attribute etag = start.getAttributeByName(etagQName);
|
||||
if (etag != null) {
|
||||
entity.setETag(etag.getValue());
|
||||
}
|
||||
|
||||
boolean foundEndEntry = false;
|
||||
while (reader.hasNext() && !foundEndEntry) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
|
||||
if (event.isStartElement()) {
|
||||
if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
|
||||
common(reader, event.asStartElement(), entity, "id");
|
||||
} else if (Constants.QNAME_ATOM_ELEM_CATEGORY.equals(event.asStartElement().getName())) {
|
||||
final Attribute term = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_TERM));
|
||||
if (term != null) {
|
||||
entity.setType(new EdmTypeInfo.Builder().setTypeExpression(term.getValue()).build().internal());
|
||||
}
|
||||
} else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
|
||||
final Link link = new Link();
|
||||
final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
|
||||
if (rel != null) {
|
||||
link.setRel(rel.getValue());
|
||||
}
|
||||
final Attribute title = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TITLE));
|
||||
if (title != null) {
|
||||
link.setTitle(title.getValue());
|
||||
}
|
||||
final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
|
||||
if (href != null) {
|
||||
link.setBindingLink(href.getValue());
|
||||
}
|
||||
final Attribute linktype = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
|
||||
if (linktype != null) {
|
||||
link.setType(linktype.getValue());
|
||||
}
|
||||
if (Constants.SELF_LINK_REL.equals(link.getRel())) {
|
||||
entity.setSelfLink(link);
|
||||
} else if (Constants.EDIT_LINK_REL.equals(link.getRel())) {
|
||||
entity.setEditLink(link);
|
||||
} else if (Constants.EDITMEDIA_LINK_REL.equals(link.getRel())) {
|
||||
final Attribute mediaETag = event.asStartElement().getAttributeByName(etagQName);
|
||||
if (mediaETag != null) {
|
||||
entity.setMediaETag(mediaETag.getValue());
|
||||
}
|
||||
} else if (link.getRel().startsWith(Constants.NS_NAVIGATION_LINK_REL)) {
|
||||
inline(reader, event.asStartElement(), link, edmEntityType);
|
||||
if (link.getInlineEntity() == null && link.getInlineEntitySet() == null) {
|
||||
entity.getNavigationBindings().add(link);
|
||||
} else {
|
||||
if (link.getInlineEntitySet() != null) {
|
||||
List<String> bindings = new ArrayList<String>();
|
||||
List<Entity> enities = link.getInlineEntitySet().getEntities();
|
||||
|
||||
for (Entity inlineEntity:enities) {
|
||||
// check if this is reference
|
||||
if (inlineEntity.getId() != null && inlineEntity.getProperties().isEmpty()) {
|
||||
bindings.add(inlineEntity.getId().toASCIIString());
|
||||
}
|
||||
}
|
||||
if (!bindings.isEmpty()) {
|
||||
link.setInlineEntitySet(null);
|
||||
link.setBindingLinks(bindings);
|
||||
entity.getNavigationBindings().add(link);
|
||||
} else {
|
||||
entity.getNavigationLinks().add(link);
|
||||
}
|
||||
} else {
|
||||
// add link
|
||||
entity.getNavigationLinks().add(link);
|
||||
}
|
||||
}
|
||||
} else if (link.getRel().startsWith(Constants.NS_ASSOCIATION_LINK_REL)) {
|
||||
entity.getAssociationLinks().add(link);
|
||||
} else if (link.getRel().startsWith(Constants.NS_MEDIA_EDIT_LINK_REL)) {
|
||||
final Attribute metag = event.asStartElement().getAttributeByName(etagQName);
|
||||
if (metag != null) {
|
||||
link.setMediaETag(metag.getValue());
|
||||
}
|
||||
entity.getMediaEditLinks().add(link);
|
||||
}
|
||||
} else if (Constants.QNAME_ATOM_ELEM_CONTENT.equals(event.asStartElement().getName())) {
|
||||
final Attribute contenttype = event.asStartElement()
|
||||
.getAttributeByName(QName.valueOf(Constants.ATTR_TYPE));
|
||||
if (contenttype == null || ContentType.APPLICATION_XML.toContentTypeString()
|
||||
.equals(contenttype.getValue())) {
|
||||
properties(reader, skipBeforeFirstStartElement(reader), entity, edmEntityType);
|
||||
} else {
|
||||
entity.setMediaContentType(contenttype.getValue());
|
||||
final Attribute src = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATOM_ATTR_SRC));
|
||||
if (src != null) {
|
||||
entity.setMediaContentSource(URI.create(src.getValue()));
|
||||
}
|
||||
}
|
||||
} else if (propertiesQName.equals(event.asStartElement().getName())) {
|
||||
properties(reader, event.asStartElement(), entity, edmEntityType);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndEntry = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeserializerResult entity(InputStream input, EdmEntityType edmEntityType)
|
||||
throws DeserializerException {
|
||||
try {
|
||||
final XMLEventReader reader = getReader(input);
|
||||
final StartElement start = skipBeforeFirstStartElement(reader);
|
||||
final Entity entity = entity(reader, start, edmEntityType);
|
||||
if (entity == null) {
|
||||
throw new DeserializerException("No entity found!", DeserializerException.MessageKeys.INVALID_ENTITY);
|
||||
}
|
||||
return DeserializerResultImpl.with().entity(entity)
|
||||
.build();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new DeserializerException(e.getMessage(), e,
|
||||
DeserializerException.MessageKeys.IO_EXCEPTION);
|
||||
} catch (final EdmPrimitiveTypeException e) {
|
||||
throw new DeserializerException(e.getMessage(), e,
|
||||
DeserializerException.MessageKeys.INVALID_ENTITY);
|
||||
}
|
||||
}
|
||||
|
||||
private void count(final XMLEventReader reader, final StartElement start, final EntityCollection entitySet)
|
||||
throws XMLStreamException {
|
||||
|
||||
boolean foundEndElement = false;
|
||||
while (reader.hasNext() && !foundEndElement) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
|
||||
entitySet.setCount(Integer.valueOf(event.asCharacters().getData()));
|
||||
}
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndElement = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private EntityCollection entitySet(final XMLEventReader reader, final StartElement start,
|
||||
final EdmEntityType edmEntityType) throws XMLStreamException, EdmPrimitiveTypeException,
|
||||
DeserializerException {
|
||||
if (!Constants.QNAME_ATOM_ELEM_FEED.equals(start.getName())) {
|
||||
return null;
|
||||
}
|
||||
final EntityCollection entitySet = new EntityCollection();
|
||||
final Attribute xmlBase = start.getAttributeByName(Constants.QNAME_ATTR_XML_BASE);
|
||||
if (xmlBase != null) {
|
||||
entitySet.setBaseURI(URI.create(xmlBase.getValue()));
|
||||
}
|
||||
|
||||
boolean foundEndFeed = false;
|
||||
while (reader.hasNext() && !foundEndFeed) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
if (event.isStartElement()) {
|
||||
if (countQName.equals(event.asStartElement().getName())) {
|
||||
count(reader, event.asStartElement(), entitySet);
|
||||
} else if (Constants.QNAME_ATOM_ELEM_ID.equals(event.asStartElement().getName())) {
|
||||
common(reader, event.asStartElement(), entitySet, "id");
|
||||
} else if (Constants.QNAME_ATOM_ELEM_LINK.equals(event.asStartElement().getName())) {
|
||||
final Attribute rel = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_REL));
|
||||
if (rel != null) {
|
||||
if (Constants.NEXT_LINK_REL.equals(rel.getValue())) {
|
||||
final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
|
||||
if (href != null) {
|
||||
entitySet.setNext(URI.create(href.getValue()));
|
||||
}
|
||||
}
|
||||
if (Constants.NS_DELTA_LINK_REL.equals(rel.getValue())) {
|
||||
final Attribute href = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_HREF));
|
||||
if (href != null) {
|
||||
entitySet.setDeltaLink(URI.create(href.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Constants.QNAME_ATOM_ELEM_ENTRY.equals(event.asStartElement().getName())) {
|
||||
entitySet.getEntities().add(entity(reader, event.asStartElement(), edmEntityType));
|
||||
} else if (entryRefQName.equals(event.asStartElement().getName())) {
|
||||
entitySet.getEntities().add(entityRef(event.asStartElement()));
|
||||
}
|
||||
}
|
||||
|
||||
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
|
||||
foundEndFeed = true;
|
||||
}
|
||||
}
|
||||
return entitySet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeserializerResult entityCollection(InputStream input, EdmEntityType edmEntityType)
|
||||
throws DeserializerException {
|
||||
try {
|
||||
final XMLEventReader reader = getReader(input);
|
||||
final StartElement start = skipBeforeFirstStartElement(reader);
|
||||
EntityCollection entityCollection = entitySet(reader, start, edmEntityType);
|
||||
for (Entity entity:entityCollection.getEntities()) {
|
||||
entity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
}
|
||||
return DeserializerResultImpl.with().entityCollection(entityCollection)
|
||||
.build();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new DeserializerException(e.getMessage(), e, DeserializerException.MessageKeys.IO_EXCEPTION);
|
||||
} catch (final EdmPrimitiveTypeException e) {
|
||||
throw new DeserializerException(e.getMessage(), e,
|
||||
DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeserializerResult entityReferences(InputStream stream) throws DeserializerException {
|
||||
try {
|
||||
XMLEventReader reader = getReader(stream);
|
||||
ArrayList<URI> references = new ArrayList<URI>();
|
||||
|
||||
while (reader.hasNext()) {
|
||||
final XMLEvent event = reader.nextEvent();
|
||||
if (event.isStartElement()) {
|
||||
StartElement start = event.asStartElement();
|
||||
if (REF_ELEMENT.equals(start.getName())) {
|
||||
Attribute context = start.getAttributeByName(ID_ATTR);
|
||||
if (context == null) {
|
||||
context = start.getAttributeByName(new QName("id"));
|
||||
}
|
||||
URI uri = URI.create(context.getValue());
|
||||
references.add(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
return DeserializerResultImpl.with().entityReferences(references).build();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new DeserializerException("An IOException occurred", e.getCause(),
|
||||
DeserializerException.MessageKeys.IO_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeserializerResult actionParameters(InputStream stream, EdmAction edmAction)
|
||||
throws DeserializerException {
|
||||
throw new DeserializerException("Not implemented", DeserializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
* 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.server.core.serializer.xml;
|
||||
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
|
||||
import org.apache.olingo.server.api.ODataServerError;
|
||||
import org.apache.olingo.server.api.ServiceMetadata;
|
||||
import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
|
||||
import org.apache.olingo.server.api.serializer.EntityCollectionSerializerOptions;
|
||||
import org.apache.olingo.server.api.serializer.EntitySerializerOptions;
|
||||
import org.apache.olingo.server.api.serializer.ODataSerializer;
|
||||
import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
|
||||
import org.apache.olingo.server.api.serializer.ReferenceCollectionSerializerOptions;
|
||||
import org.apache.olingo.server.api.serializer.ReferenceSerializerOptions;
|
||||
import org.apache.olingo.server.api.serializer.SerializerException;
|
||||
import org.apache.olingo.server.api.serializer.SerializerResult;
|
||||
import org.apache.olingo.server.core.serializer.SerializerResultImpl;
|
||||
import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ODataXmlSerializerImpl implements ODataSerializer {
|
||||
|
||||
/** The default character set is UTF-8. */
|
||||
public static final String DEFAULT_CHARSET = "UTF-8";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ODataXmlSerializerImpl.class);
|
||||
|
||||
@Override
|
||||
public SerializerResultImpl serviceDocument(final ServiceMetadata metadata, final String serviceRoot)
|
||||
throws SerializerException {
|
||||
throw new SerializerException("Service Document not implemented for XML format",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult metadataDocument(final ServiceMetadata serviceMetadata) throws SerializerException {
|
||||
CircleStreamBuffer buffer;
|
||||
XMLStreamWriter xmlStreamWriter = null;
|
||||
|
||||
try {
|
||||
buffer = new CircleStreamBuffer();
|
||||
xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(buffer.getOutputStream(), DEFAULT_CHARSET);
|
||||
MetadataDocumentXmlSerializer serializer = new MetadataDocumentXmlSerializer(serviceMetadata);
|
||||
serializer.writeMetadataDocument(xmlStreamWriter);
|
||||
xmlStreamWriter.flush();
|
||||
xmlStreamWriter.close();
|
||||
|
||||
return SerializerResultImpl.with().content(buffer.getInputStream()).build();
|
||||
} catch (final XMLStreamException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new SerializerException("An I/O exception occurred.", e,
|
||||
SerializerException.MessageKeys.IO_EXCEPTION);
|
||||
} finally {
|
||||
if (xmlStreamWriter != null) {
|
||||
try {
|
||||
xmlStreamWriter.close();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new SerializerException("An I/O exception occurred.", e,
|
||||
SerializerException.MessageKeys.IO_EXCEPTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult entity(final ServiceMetadata metadata, final EdmEntityType entityType,
|
||||
final Entity entity, final EntitySerializerOptions options) throws SerializerException {
|
||||
throw new SerializerException("Entity serialization not implemented for XML format",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult entityCollection(final ServiceMetadata metadata,
|
||||
final EdmEntityType entityType, final EntityCollection entitySet,
|
||||
final EntityCollectionSerializerOptions options) throws SerializerException {
|
||||
throw new SerializerException("Entityset serialization not implemented for XML format",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult error(final ODataServerError error) throws SerializerException {
|
||||
throw new SerializerException("error serialization not implemented for XML format",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult primitive(final ServiceMetadata metadata, final EdmPrimitiveType type,
|
||||
final Property property, final PrimitiveSerializerOptions options) throws SerializerException {
|
||||
throw new SerializerException("Serialization not implemented for XML format.",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult complex(final ServiceMetadata metadata, final EdmComplexType type,
|
||||
final Property property, final ComplexSerializerOptions options) throws SerializerException {
|
||||
throw new SerializerException("Serialization not implemented for XML format.",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult primitiveCollection(final ServiceMetadata metadata, final EdmPrimitiveType type,
|
||||
final Property property, final PrimitiveSerializerOptions options) throws SerializerException {
|
||||
throw new SerializerException("Serialization not implemented for XML format.",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult complexCollection(final ServiceMetadata metadata, final EdmComplexType type,
|
||||
final Property property, final ComplexSerializerOptions options) throws SerializerException {
|
||||
throw new SerializerException("Serialization not implemented for XML format.",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult reference(final ServiceMetadata metadata, final EdmEntitySet edmEntotySet,
|
||||
final Entity entity, final ReferenceSerializerOptions options) throws SerializerException {
|
||||
throw new SerializerException("Serialization not implemented for XML format.",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult referenceCollection(final ServiceMetadata metadata, final EdmEntitySet edmEntitySet,
|
||||
final EntityCollection entityCollection, final ReferenceCollectionSerializerOptions optionsL)
|
||||
throws SerializerException {
|
||||
throw new SerializerException("Serialization not implemented for XML format.",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* 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.server.core.serializer.xml;
|
||||
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
|
||||
import org.apache.olingo.commons.api.edm.EdmSingleton;
|
||||
import org.apache.olingo.server.api.ServiceMetadata;
|
||||
import org.apache.olingo.server.api.edmx.EdmxReference;
|
||||
import org.apache.olingo.server.api.serializer.ODataSerializer;
|
||||
|
||||
public class ServiceDocumentXmlSerializer {
|
||||
public static final String KIND = "kind";
|
||||
|
||||
public static final String FUNCTION_IMPORT = "FunctionImport";
|
||||
public static final String SINGLETON = "Singleton";
|
||||
public static final String SERVICE_DOCUMENT = "ServiceDocument";
|
||||
|
||||
private static final String APP = "app";
|
||||
private static final String NS_APP = "http://www.w3.org/2007/app";
|
||||
private static final String ATOM = "atom";
|
||||
private static final String NS_ATOM = "http://www.w3.org/2005/Atom";
|
||||
private static final String METADATA = "metadata";
|
||||
private static final String NS_METADATA = "http://docs.oasis-open.org/odata/ns/metadata";
|
||||
|
||||
private final ServiceMetadata metadata;
|
||||
private final String serviceRoot;
|
||||
|
||||
public ServiceDocumentXmlSerializer(final ServiceMetadata metadata, final String serviceRoot) {
|
||||
this.metadata = metadata;
|
||||
this.serviceRoot = serviceRoot;
|
||||
}
|
||||
|
||||
public void writeServiceDocument(final XMLStreamWriter writer) throws XMLStreamException {
|
||||
final String metadataUri =
|
||||
(serviceRoot == null ? "" : serviceRoot.endsWith("/") ? serviceRoot : (serviceRoot + "/"))
|
||||
+ Constants.METADATA;
|
||||
|
||||
writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0");
|
||||
writer.writeStartElement(APP, "service", NS_APP);
|
||||
writer.writeNamespace(ATOM, NS_ATOM);
|
||||
writer.writeNamespace(APP, NS_APP);
|
||||
writer.writeNamespace(METADATA, NS_METADATA);
|
||||
writer.writeAttribute(METADATA, NS_METADATA, "context", metadataUri);
|
||||
|
||||
if (metadata != null
|
||||
&& metadata.getServiceMetadataETagSupport() != null
|
||||
&& metadata.getServiceMetadataETagSupport().getMetadataETag() != null) {
|
||||
writer.writeAttribute(METADATA, NS_METADATA, "metadata-etag",
|
||||
metadata.getServiceMetadataETagSupport().getMetadataETag());
|
||||
}
|
||||
|
||||
writer.writeStartElement(APP, "workspace", NS_APP);
|
||||
|
||||
final Edm edm = metadata.getEdm();
|
||||
|
||||
writer.writeStartElement(ATOM, "title", NS_APP);
|
||||
writer.writeCharacters(edm.getEntityContainer(null).getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
writer.writeEndElement();
|
||||
|
||||
writeEntitySets(writer, edm);
|
||||
writeFunctionImports(writer, edm);
|
||||
writeSingletons(writer, edm);
|
||||
writeServiceDocuments(writer);
|
||||
writer.writeEndElement(); // end workspace
|
||||
writer.writeEndElement(); // end service
|
||||
}
|
||||
|
||||
private void writeServiceDocuments(XMLStreamWriter writer) throws XMLStreamException {
|
||||
|
||||
for (EdmxReference reference : this.metadata.getReferences()) {
|
||||
writer.writeStartElement(METADATA , "service-document", NS_METADATA);
|
||||
writer.writeAttribute("href", reference.getUri().toASCIIString());
|
||||
writer.writeStartElement(ATOM, "title", NS_ATOM);
|
||||
writer.writeCharacters(reference.getUri().toASCIIString());
|
||||
writer.writeEndElement();
|
||||
writer.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeEntitySets(final XMLStreamWriter writer, final Edm edm) throws XMLStreamException {
|
||||
EdmEntityContainer container = edm.getEntityContainer(null);
|
||||
for (EdmEntitySet edmEntitySet : container.getEntitySets()) {
|
||||
if (edmEntitySet.isIncludeInServiceDocument()) {
|
||||
writer.writeStartElement(APP, "collection", NS_APP);
|
||||
writer.writeAttribute("href", edmEntitySet.getName());
|
||||
writer.writeStartElement(ATOM, "title", NS_ATOM);
|
||||
writer.writeCharacters(edmEntitySet.getName());
|
||||
writer.writeEndElement();
|
||||
writer.writeEndElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFunctionImports(final XMLStreamWriter writer, final Edm edm) throws XMLStreamException {
|
||||
EdmEntityContainer container = edm.getEntityContainer(null);
|
||||
|
||||
for (EdmFunctionImport edmFunctionImport : container.getFunctionImports()) {
|
||||
if (edmFunctionImport.isIncludeInServiceDocument()) {
|
||||
writer.writeStartElement(METADATA, "function-import", NS_METADATA);
|
||||
writer.writeAttribute("href", edmFunctionImport.getName());
|
||||
writer.writeStartElement(ATOM, "title", NS_ATOM);
|
||||
writer.writeCharacters(edmFunctionImport.getName());
|
||||
writer.writeEndElement();
|
||||
writer.writeEndElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeSingletons(final XMLStreamWriter writer, final Edm edm) throws XMLStreamException {
|
||||
EdmEntityContainer container = edm.getEntityContainer(null);
|
||||
for (EdmSingleton edmSingleton : container.getSingletons()) {
|
||||
writer.writeStartElement(METADATA, "singleton", NS_METADATA);
|
||||
writer.writeAttribute("href", edmSingleton.getName());
|
||||
writer.writeStartElement(ATOM, "title", NS_ATOM);
|
||||
writer.writeCharacters( edmSingleton.getName());
|
||||
writer.writeEndElement();
|
||||
writer.writeEndElement();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -78,6 +78,8 @@ public class ContentNegotiatorTest {
|
|||
{ ACCEPT_CASE_MIN_IEEE754, null, ACCEPT_CASE_MIN_IEEE754, null },
|
||||
{ ACCEPT_CASE_MIN_UTF8_IEEE754, null, ACCEPT_CASE_MIN_UTF8_IEEE754, null },
|
||||
{ ACCEPT_CASE_MIN_IEEE754, ACCEPT_CASE_MIN_IEEE754, ACCEPT_CASE_MIN , null },
|
||||
{ ACCEPT_CASE_XML, "xml", null, null },
|
||||
{ ACCEPT_CASE_XML, null, ACCEPT_CASE_XML, null }
|
||||
};
|
||||
|
||||
String[][] casesMetadata = {
|
||||
|
@ -99,7 +101,6 @@ public class ContentNegotiatorTest {
|
|||
{ null, "a/a", null, "b/b" },
|
||||
{ null, "a/a;x=y", null, "a/a;v=w" },
|
||||
{ null, null, "a/a;x=y", "a/a;v=w" },
|
||||
{ null, "atom", null, null }, // not yet supported
|
||||
{ null, null, ACCEPT_CASE_FULL, null }, // not yet supported
|
||||
{ null, "a/b;charset=ISO-8859-1", null, "a/b" },
|
||||
{ null, null, "a/b;charset=ISO-8859-1", "a/b" },
|
||||
|
|
|
@ -50,8 +50,7 @@ public class ODataImplTest {
|
|||
assertNotNull(odata.createDeserializer(ContentType.APPLICATION_JSON));
|
||||
}
|
||||
|
||||
@Test(expected = DeserializerException.class)
|
||||
public void xmlDeserializer() throws DeserializerException {
|
||||
odata.createDeserializer(ContentType.APPLICATION_XML);
|
||||
assertNotNull(odata.createDeserializer(ContentType.APPLICATION_XML));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.apache.olingo.commons.api.edm.provider.CsdlAliasInfo;
|
|||
import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainer;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlEntityContainerInfo;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlEnumMember;
|
||||
|
@ -73,7 +74,7 @@ import org.junit.Test;
|
|||
public class MetadataDocumentXmlSerializerTest {
|
||||
|
||||
private static ODataSerializer serializer;
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void init() throws SerializerException {
|
||||
serializer = OData.newInstance().createSerializer(ContentType.APPLICATION_XML);
|
||||
|
@ -263,7 +264,7 @@ public class MetadataDocumentXmlSerializerTest {
|
|||
+ "</ComplexType>"));
|
||||
}
|
||||
|
||||
private class LocalProvider extends CsdlAbstractEdmProvider {
|
||||
static class LocalProvider extends CsdlAbstractEdmProvider {
|
||||
private final static String nameSpace = "namespace";
|
||||
|
||||
private final FullQualifiedName nameETAbstract = new FullQualifiedName(nameSpace, "ETAbstract");
|
||||
|
@ -468,6 +469,15 @@ public class MetadataDocumentXmlSerializerTest {
|
|||
return schemas;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsdlEntityContainerInfo getEntityContainerInfo(final FullQualifiedName entityContainerName)
|
||||
throws ODataException {
|
||||
if (entityContainerName == null) {
|
||||
return new CsdlEntityContainerInfo().setContainerName(new FullQualifiedName("org.olingo", "container"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsdlEntityContainer getEntityContainer() throws ODataException {
|
||||
CsdlEntityContainer container = new CsdlEntityContainer();
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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.server.core.serializer.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.olingo.commons.api.ODataErrorDetail;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.server.api.OData;
|
||||
import org.apache.olingo.server.api.ODataServerError;
|
||||
import org.apache.olingo.server.api.serializer.ODataSerializer;
|
||||
import org.apache.olingo.server.api.serializer.SerializerException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ServerErrorXmlSerializerTest {
|
||||
|
||||
ODataSerializer ser;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
ser = OData.newInstance().createSerializer(ContentType.APPLICATION_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicODataErrorWithCode() throws Exception {
|
||||
ODataServerError error = new ODataServerError();
|
||||
error.setCode("Code").setMessage("ErrorMessage");
|
||||
InputStream stream = ser.error(error).getContent();
|
||||
String jsonString = IOUtils.toString(stream);
|
||||
assertEquals("<?xml version='1.0' encoding='UTF-8'?>"
|
||||
+ "<error xmlns=\"http://docs.oasis-open.org/odata/ns/metadata\">"
|
||||
+ "<code>0</code>"
|
||||
+ "<message>ErrorMessage</message>"
|
||||
+ "</error>",
|
||||
jsonString);
|
||||
}
|
||||
|
||||
@Test(expected = SerializerException.class)
|
||||
public void nullErrorResultsInException() throws Exception {
|
||||
ser.error(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleDetailNothingSet() throws Exception {
|
||||
ODataErrorDetail detail = new ODataErrorDetail();
|
||||
detail.setCode("detail code");
|
||||
detail.setMessage("detail message");
|
||||
|
||||
List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
|
||||
details.add(detail);
|
||||
|
||||
ODataServerError error = new ODataServerError().setDetails(details);
|
||||
error.setCode("code");
|
||||
error.setMessage("err message");
|
||||
error.setTarget("target");
|
||||
|
||||
InputStream stream = ser.error(error).getContent();
|
||||
String jsonString = IOUtils.toString(stream);
|
||||
assertEquals("<?xml version='1.0' encoding='UTF-8'?>"
|
||||
+ "<error xmlns=\"http://docs.oasis-open.org/odata/ns/metadata\">"
|
||||
+ "<code>0</code>"
|
||||
+ "<message>err message</message>"
|
||||
+ "<target>target</target>"
|
||||
+ "<details>"
|
||||
+ "<code>detail code</code>"
|
||||
+ "<message>detail message</message>"
|
||||
+ "</details>"
|
||||
+ "</error>",
|
||||
jsonString);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* 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.server.core.serializer.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmFunctionImport;
|
||||
import org.apache.olingo.commons.api.edm.EdmSingleton;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.server.api.OData;
|
||||
import org.apache.olingo.server.api.ServiceMetadata;
|
||||
import org.apache.olingo.server.api.edmx.EdmxReference;
|
||||
import org.apache.olingo.server.api.serializer.ODataSerializer;
|
||||
import org.apache.olingo.server.api.serializer.SerializerException;
|
||||
import org.apache.olingo.server.core.ServiceMetadataImpl;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
public class ServiceDocumentXmlSerializerTest {
|
||||
private static ODataSerializer serializer;
|
||||
|
||||
@BeforeClass
|
||||
public static void init() throws SerializerException {
|
||||
serializer = OData.newInstance().createSerializer(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeServiceWithEmptyMockedEdm() throws Exception {
|
||||
final Edm edm = mock(Edm.class);
|
||||
EdmEntityContainer container = mock(EdmEntityContainer.class);
|
||||
Mockito.stub(container.getFullQualifiedName()).toReturn(new FullQualifiedName("service.test"));
|
||||
when(container.getEntitySets()).thenReturn(new ArrayList<EdmEntitySet>());
|
||||
when(container.getFunctionImports()).thenReturn(new ArrayList<EdmFunctionImport>());
|
||||
when(container.getSingletons()).thenReturn(new ArrayList<EdmSingleton>());
|
||||
when(edm.getEntityContainer(null)).thenReturn(container);
|
||||
ServiceMetadata metadata = mock(ServiceMetadata.class);
|
||||
when(metadata.getEdm()).thenReturn(edm);
|
||||
|
||||
assertEquals("<?xml version='1.0' encoding='UTF-8'?>"
|
||||
+ "<app:service xmlns:atom=\"http://www.w3.org/2005/Atom\" "
|
||||
+ "xmlns:app=\"http://www.w3.org/2007/app\" "
|
||||
+ "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
|
||||
+ "metadata:context=\"http://host/svc/$metadata\">"
|
||||
+ "<app:workspace><atom:title>service.test</atom:title></app:workspace>"
|
||||
+ "</app:service>",
|
||||
IOUtils.toString(serializer.serviceDocument(metadata, "http://host/svc").getContent()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeServiceDocument() throws Exception {
|
||||
CsdlEdmProvider provider = new MetadataDocumentXmlSerializerTest.LocalProvider();
|
||||
ServiceMetadata serviceMetadata = new ServiceMetadataImpl(provider,
|
||||
Collections.<EdmxReference> emptyList(), null);
|
||||
InputStream metadataStream = serializer.serviceDocument(serviceMetadata, "http://host/svc").getContent();
|
||||
String metadata = IOUtils.toString(metadataStream);
|
||||
assertEquals("<?xml version='1.0' encoding='UTF-8'?>"
|
||||
+ "<app:service xmlns:atom=\"http://www.w3.org/2005/Atom\" "
|
||||
+ "xmlns:app=\"http://www.w3.org/2007/app\" "
|
||||
+ "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
|
||||
+ "metadata:context=\"http://host/svc/$metadata\">"
|
||||
+ "<app:workspace>"
|
||||
+ "<atom:title>org.olingo.container</atom:title>"
|
||||
+ "<app:collection href=\"ESAllPrim\">"
|
||||
+ "<atom:title>ESAllPrim</atom:title>"
|
||||
+ "</app:collection>"
|
||||
+ "<metadata:function-import href=\"FINRTInt16\">"
|
||||
+ "<atom:title>FINRTInt16</atom:title>"
|
||||
+ "</metadata:function-import>"
|
||||
+ "<metadata:singleton href=\"SI\">"
|
||||
+ "<atom:title>SI</atom:title>"
|
||||
+ "</metadata:singleton>"
|
||||
+ "</app:workspace>"
|
||||
+ "</app:service>",
|
||||
metadata);
|
||||
}
|
||||
}
|
|
@ -74,7 +74,7 @@ public class TechnicalServlet extends HttpServlet {
|
|||
HttpSession session = request.getSession(true);
|
||||
DataProvider dataProvider = (DataProvider) session.getAttribute(DataProvider.class.getName());
|
||||
if (dataProvider == null) {
|
||||
dataProvider = new DataProvider();
|
||||
dataProvider = new DataProvider(serviceMetadata.getEdm());
|
||||
session.setAttribute(DataProvider.class.getName(), dataProvider);
|
||||
LOG.info("Created new data provider.");
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.math.BigDecimal;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -36,7 +37,10 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
|||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.http.HttpStatusCode;
|
||||
import org.apache.olingo.server.api.OData;
|
||||
import org.apache.olingo.server.api.ServiceMetadata;
|
||||
import org.apache.olingo.server.api.edmx.EdmxReference;
|
||||
import org.apache.olingo.server.tecsvc.data.DataProvider.DataProviderException;
|
||||
import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
|
||||
|
||||
public class ActionData {
|
||||
|
||||
|
@ -151,6 +155,9 @@ public class ActionData {
|
|||
|
||||
protected static EntityActionResult entityAction(final String name, final Map<String, Parameter> parameters)
|
||||
throws DataProviderException {
|
||||
final ServiceMetadata metadata = OData.newInstance().createServiceMetadata(new EdmTechProvider(),
|
||||
Collections.<EdmxReference> emptyList(),null);
|
||||
|
||||
if ("UARTETTwoKeyTwoPrimParam".equals(name)) {
|
||||
Parameter parameter = parameters.get("ParameterInt16");
|
||||
Short number;
|
||||
|
@ -160,7 +167,7 @@ public class ActionData {
|
|||
number = (short) 0;
|
||||
}
|
||||
|
||||
EntityCollection entityCollection = new DataCreator().getData().get("ESTwoKeyTwoPrim");
|
||||
EntityCollection entityCollection = new DataCreator(metadata.getEdm()).getData().get("ESTwoKeyTwoPrim");
|
||||
for (Entity entity : entityCollection.getEntities()) {
|
||||
Object asPrimitive = entity.getProperty("PropertyInt16").asPrimitive();
|
||||
if (number.equals(asPrimitive)) {
|
||||
|
@ -171,7 +178,7 @@ public class ActionData {
|
|||
throw new DataProviderException("Entity not found with key: " + number, HttpStatusCode.NOT_FOUND);
|
||||
} else if ("UARTETAllPrimParam".equals(name)) {
|
||||
Parameter paramDate = parameters.get("ParameterDate");
|
||||
EntityCollection entityCollection = new DataCreator().getData().get("ESAllPrim");
|
||||
EntityCollection entityCollection = new DataCreator(metadata.getEdm()).getData().get("ESAllPrim");
|
||||
if (paramDate != null) {
|
||||
Calendar date = (Calendar) paramDate.asPrimitive();
|
||||
boolean freeKey;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.olingo.server.tecsvc.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
|
@ -37,6 +38,10 @@ import org.apache.olingo.commons.api.data.EntityCollection;
|
|||
import org.apache.olingo.commons.api.data.Link;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.data.ValueType;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
|
||||
import org.apache.olingo.server.tecsvc.provider.EntityTypeProvider;
|
||||
|
||||
public class DataCreator {
|
||||
|
||||
|
@ -44,28 +49,28 @@ public class DataCreator {
|
|||
|
||||
private final Map<String, EntityCollection> data;
|
||||
|
||||
public DataCreator() {
|
||||
public DataCreator(Edm edm) {
|
||||
data = new HashMap<String, EntityCollection>();
|
||||
data.put("ESTwoPrim", createESTwoPrim());
|
||||
data.put("ESAllPrim", createESAllPrim());
|
||||
data.put("ESCompAllPrim", createESCompAllPrim());
|
||||
data.put("ESCollAllPrim", createESCollAllPrim());
|
||||
data.put("ESMixPrimCollComp", createESMixPrimCollComp());
|
||||
data.put("ESAllKey", createESAllKey());
|
||||
data.put("ESCompComp", createESCompComp());
|
||||
data.put("ESMedia", createESMedia());
|
||||
data.put("ESKeyNav", createESKeyNav());
|
||||
data.put("ESTwoKeyNav", createESTwoKeyNav());
|
||||
data.put("ESCompCollComp", createESCompCollComp());
|
||||
data.put("ESServerSidePaging", createESServerSidePaging());
|
||||
data.put("ESTwoKeyTwoPrim", createESTwoKeyTwoPrim());
|
||||
data.put("ESAllNullable", createESAllNullable());
|
||||
data.put("ESTwoBase", createESTwoBase());
|
||||
data.put("ESBaseTwoKeyNav", createESBaseTwoKeyNav());
|
||||
data.put("ESCompCollAllPrim", createESCompCollAllPrim());
|
||||
data.put("ESFourKeyAlias", createESFourKeyAlias());
|
||||
data.put("ESBase", createESBase());
|
||||
data.put("ESCompMixPrimCollComp", createESCompMixPrimCollComp());
|
||||
data.put("ESTwoPrim", createESTwoPrim(edm));
|
||||
data.put("ESAllPrim", createESAllPrim(edm));
|
||||
data.put("ESCompAllPrim", createESCompAllPrim(edm));
|
||||
data.put("ESCollAllPrim", createESCollAllPrim(edm));
|
||||
data.put("ESMixPrimCollComp", createESMixPrimCollComp(edm));
|
||||
data.put("ESAllKey", createESAllKey(edm));
|
||||
data.put("ESCompComp", createESCompComp(edm));
|
||||
data.put("ESMedia", createESMedia(edm));
|
||||
data.put("ESKeyNav", createESKeyNav(edm));
|
||||
data.put("ESTwoKeyNav", createESTwoKeyNav(edm));
|
||||
data.put("ESCompCollComp", createESCompCollComp(edm));
|
||||
data.put("ESServerSidePaging", createESServerSidePaging(edm));
|
||||
data.put("ESTwoKeyTwoPrim", createESTwoKeyTwoPrim(edm));
|
||||
data.put("ESAllNullable", createESAllNullable(edm));
|
||||
data.put("ESTwoBase", createESTwoBase(edm));
|
||||
data.put("ESBaseTwoKeyNav", createESBaseTwoKeyNav(edm));
|
||||
data.put("ESCompCollAllPrim", createESCompCollAllPrim(edm));
|
||||
data.put("ESFourKeyAlias", createESFourKeyAlias(edm));
|
||||
data.put("ESBase", createESBase(edm));
|
||||
data.put("ESCompMixPrimCollComp", createESCompMixPrimCollComp(edm));
|
||||
|
||||
linkESTwoPrim(data);
|
||||
linkESAllPrim(data);
|
||||
|
@ -73,13 +78,17 @@ public class DataCreator {
|
|||
linkESTwoKeyNav(data);
|
||||
}
|
||||
|
||||
private EntityCollection createESCompMixPrimCollComp() {
|
||||
private EntityCollection createESCompMixPrimCollComp(Edm edm) {
|
||||
final EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(createETCompMixPrimCollComp((short) 1));
|
||||
entityCollection.getEntities().add(createETCompMixPrimCollComp((short) 2));
|
||||
entityCollection.getEntities().add(createETCompMixPrimCollComp((short) 3));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCompMixPrimCollComp);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESCompMixPrimCollComp", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
|
@ -111,7 +120,7 @@ public class DataCreator {
|
|||
));
|
||||
}
|
||||
|
||||
private EntityCollection createESBase() {
|
||||
private EntityCollection createESBase(Edm edm) {
|
||||
final EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
|
@ -129,11 +138,14 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive("PropertyString", "TEST C"))
|
||||
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST E 0815")));
|
||||
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETBase);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESBase", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESFourKeyAlias() {
|
||||
private EntityCollection createESFourKeyAlias(Edm edm) {
|
||||
final EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
|
@ -150,16 +162,22 @@ public class DataCreator {
|
|||
))
|
||||
);
|
||||
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETFourKeyAlias);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESFourKeyAlias", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESCompCollAllPrim() {
|
||||
private EntityCollection createESCompCollAllPrim(Edm edm) {
|
||||
final EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(createETCompCollAllPrim((short) 5678));
|
||||
entityCollection.getEntities().add(createETCompCollAllPrim((short) 12326));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCompCollAllPrim);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESCompCollAllPrim", entityCollection, type.getKeyPropertyRefs());
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
|
@ -244,7 +262,7 @@ public class DataCreator {
|
|||
));
|
||||
}
|
||||
|
||||
private EntityCollection createESBaseTwoKeyNav() {
|
||||
private EntityCollection createESBaseTwoKeyNav(Edm edm) {
|
||||
final EntityCollection entityCollection = new EntityCollection();
|
||||
entityCollection.getEntities().add(
|
||||
createESTwoKeyNavEntity((short) 1, "1")
|
||||
|
@ -261,10 +279,15 @@ public class DataCreator {
|
|||
entityCollection.getEntities().add(
|
||||
createESTwoKeyNavEntity((short) 3, "1")
|
||||
.addProperty(createPrimitive("PropertyDate", getDateTime(2013, 12, 12, 0, 0, 0))));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESBaseTwoKeyNav", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESTwoBase() {
|
||||
private EntityCollection createESTwoBase(Edm edm) {
|
||||
final EntityCollection entityCollection = new EntityCollection();
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
.addProperty(createPrimitive("PropertyInt16",(short) 111))
|
||||
|
@ -284,10 +307,14 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST E 0815"))
|
||||
.addProperty(createPrimitive("AdditionalPropertyString_6", "TEST F 0815")));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETTwoBase);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESTwoBase", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESAllNullable() {
|
||||
private EntityCollection createESAllNullable(Edm edm) {
|
||||
final EntityCollection entityCollection = new EntityCollection();
|
||||
entityCollection.getEntities().add(
|
||||
new Entity()
|
||||
|
@ -374,7 +401,9 @@ public class DataCreator {
|
|||
getTime(0, 37, 13))
|
||||
));
|
||||
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETAllNullable);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESAllNullable", entityCollection, type.getKeyPropertyRefs());
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
|
@ -382,11 +411,16 @@ public class DataCreator {
|
|||
return data;
|
||||
}
|
||||
|
||||
private EntityCollection createESTwoKeyTwoPrim() {
|
||||
private EntityCollection createESTwoKeyTwoPrim(Edm edm) {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
entityCollection.getEntities().add(createETTwoKeyTwoPrimEntity((short) 32767, "Test String1"));
|
||||
entityCollection.getEntities().add(createETTwoKeyTwoPrimEntity((short) -365, "Test String2"));
|
||||
entityCollection.getEntities().add(createETTwoKeyTwoPrimEntity((short) -32766, "Test String3"));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETTwoKeyTwoPrim);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESTwoKeyTwoPrim", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
|
@ -396,7 +430,7 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive("PropertyString", propertyString));
|
||||
}
|
||||
|
||||
private EntityCollection createESServerSidePaging() {
|
||||
private EntityCollection createESServerSidePaging(Edm edm) {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
for (short i = 1; i <= 503; i++) {
|
||||
|
@ -405,16 +439,24 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive("PropertyString", "Number:" + i)));
|
||||
}
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETServerSidePaging);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESServerSidePaging", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESKeyNav() {
|
||||
private EntityCollection createESKeyNav(Edm edm) {
|
||||
final EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(createETKeyNavEntity((short) 1, "I am String Property 1"));
|
||||
entityCollection.getEntities().add(createETKeyNavEntity((short) 2, "I am String Property 2"));
|
||||
entityCollection.getEntities().add(createETKeyNavEntity((short) 3, "I am String Property 3"));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESKeyNav", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
|
@ -453,7 +495,7 @@ public class DataCreator {
|
|||
createPrimitive("PropertyInt16",(short) 1))));
|
||||
}
|
||||
|
||||
private EntityCollection createESTwoKeyNav() {
|
||||
private EntityCollection createESTwoKeyNav(Edm edm) {
|
||||
final EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(createESTwoKeyNavEntity((short) 1, "1"));
|
||||
|
@ -461,6 +503,10 @@ public class DataCreator {
|
|||
entityCollection.getEntities().add(createESTwoKeyNavEntity((short) 2, "1"));
|
||||
entityCollection.getEntities().add(createESTwoKeyNavEntity((short) 3, "1"));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETTwoKeyNav);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESTwoKeyNav", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
|
@ -521,7 +567,7 @@ public class DataCreator {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private EntityCollection createESCompCollComp() {
|
||||
private EntityCollection createESCompCollComp(Edm edm) {
|
||||
final EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
|
@ -552,10 +598,14 @@ public class DataCreator {
|
|||
createPrimitive("PropertyInt16",(short) 0),
|
||||
createPrimitive("PropertyString", "13 Test Complex in Complex Property"))))));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCompCollComp);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESCompCollComp", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESTwoPrim() {
|
||||
private EntityCollection createESTwoPrim(Edm edm) {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
|
@ -574,10 +624,19 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive("PropertyInt16", Short.MAX_VALUE))
|
||||
.addProperty(createPrimitive("PropertyString", "Test String4")));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETTwoPrim);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESTwoPrim", entityCollection, type.getKeyPropertyRefs());
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESAllPrim() {
|
||||
private void setEntityType(EntityCollection entityCollection, EdmEntityType type) {
|
||||
for (Entity entity:entityCollection.getEntities()) {
|
||||
entity.setType(type.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
}
|
||||
}
|
||||
|
||||
private EntityCollection createESAllPrim(Edm edm) {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
|
@ -636,10 +695,14 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive("PropertyGuid", UUID.fromString("76543201-23ab-cdef-0123-456789cccddd")))
|
||||
.addProperty(createPrimitive("PropertyTimeOfDay", getTime(0, 1, 1))));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETAllPrim);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESAllPrim", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESCompAllPrim() {
|
||||
private EntityCollection createESCompAllPrim(Edm edm) {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
Entity entity = new Entity()
|
||||
|
@ -730,19 +793,27 @@ public class DataCreator {
|
|||
createPrimitive("PropertyInt64", null),
|
||||
createPrimitive("PropertySByte", null),
|
||||
createPrimitive("PropertyTimeOfDay", null)));
|
||||
entity.setETag("W/\"-32768\"");
|
||||
entityCollection.getEntities().add(entity);
|
||||
|
||||
entity.setETag("W/\"-32768\"");
|
||||
entityCollection.getEntities().add(entity);
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCompAllPrim);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESCompAllPrim", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESCollAllPrim() {
|
||||
private EntityCollection createESCollAllPrim(Edm edm) {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(createETCollAllPrim((short) 1));
|
||||
entityCollection.getEntities().add(createETCollAllPrim((short) 2));
|
||||
entityCollection.getEntities().add(createETCollAllPrim((short) 3));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCollAllPrim);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESCollAllPrim", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
|
@ -815,7 +886,7 @@ public class DataCreator {
|
|||
getTime(1, 12, 33)));
|
||||
}
|
||||
|
||||
private EntityCollection createESMixPrimCollComp() {
|
||||
private EntityCollection createESMixPrimCollComp(Edm edm) {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
|
@ -841,7 +912,7 @@ public class DataCreator {
|
|||
.addProperty(createColPropertyComp()));
|
||||
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
.addProperty(createPrimitive("PropertyInt16", 0))
|
||||
.addProperty(createPrimitive("PropertyInt16", (short)0))
|
||||
.addProperty(createPrimitiveCollection("CollPropertyString",
|
||||
"Employee1@company.example",
|
||||
"Employee2@company.example",
|
||||
|
@ -851,6 +922,10 @@ public class DataCreator {
|
|||
createPrimitive("PropertyString", "TEST C")))
|
||||
.addProperty(createColPropertyComp()));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETMixPrimCollComp);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESMixPrimCollComp", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
|
@ -868,7 +943,7 @@ public class DataCreator {
|
|||
createPrimitive("PropertyString", "TEST 3")));
|
||||
}
|
||||
|
||||
private EntityCollection createESAllKey() {
|
||||
private EntityCollection createESAllKey(Edm edm) {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
entityCollection.getEntities().add(new Entity()
|
||||
|
@ -900,11 +975,15 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive("PropertyDuration", BigDecimal.valueOf(6)))
|
||||
.addProperty(createPrimitive("PropertyGuid", GUID))
|
||||
.addProperty(createPrimitive("PropertyTimeOfDay", getTime(2, 48, 21))));
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETAllKey);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESAllKey", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESCompComp() {
|
||||
private EntityCollection createESCompComp(Edm edm) {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
Entity entity = new Entity();
|
||||
|
@ -923,10 +1002,14 @@ public class DataCreator {
|
|||
createPrimitive("PropertyString", "String 2"))));
|
||||
entityCollection.getEntities().add(entity);
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETCompComp);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESCompComp", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
private EntityCollection createESMedia() {
|
||||
private EntityCollection createESMedia(Edm edm) {
|
||||
EntityCollection entityCollection = new EntityCollection();
|
||||
|
||||
Entity entity = new Entity()
|
||||
|
@ -934,6 +1017,7 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("darkturquoise")));
|
||||
entity.setMediaContentType("image/svg+xml");
|
||||
entity.setMediaETag("W/\"1\"");
|
||||
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(1)/$value"));
|
||||
entityCollection.getEntities().add(entity);
|
||||
|
||||
entity = new Entity()
|
||||
|
@ -941,6 +1025,7 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("royalblue")));
|
||||
entity.setMediaContentType("image/svg+xml");
|
||||
entity.setMediaETag("W/\"2\"");
|
||||
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(2)/$value"));
|
||||
entityCollection.getEntities().add(entity);
|
||||
|
||||
entity = new Entity()
|
||||
|
@ -948,6 +1033,7 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("crimson")));
|
||||
entity.setMediaContentType("image/svg+xml");
|
||||
entity.setMediaETag("W/\"3\"");
|
||||
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(3)/$value"));
|
||||
entityCollection.getEntities().add(entity);
|
||||
|
||||
entity = new Entity()
|
||||
|
@ -955,8 +1041,13 @@ public class DataCreator {
|
|||
.addProperty(createPrimitive(DataProvider.MEDIA_PROPERTY_NAME, createImage("black")));
|
||||
entity.setMediaContentType("image/svg+xml");
|
||||
entity.setMediaETag("W/\"4\"");
|
||||
entity.getMediaEditLinks().add(buildMediaLink("ESMedia", "ESMedia(4)/$value"));
|
||||
entityCollection.getEntities().add(entity);
|
||||
|
||||
EdmEntityType type = edm.getEntityType(EntityTypeProvider.nameETMedia);
|
||||
setEntityType(entityCollection, type);
|
||||
createEntityId("ESMedia", entityCollection, type.getKeyPropertyRefs());
|
||||
|
||||
return entityCollection;
|
||||
}
|
||||
|
||||
|
@ -1116,12 +1207,22 @@ public class DataCreator {
|
|||
return timestamp;
|
||||
}
|
||||
|
||||
protected static Link buildMediaLink(String title, String href) {
|
||||
Link link = new Link();
|
||||
link.setRel("edit-media");
|
||||
link.setTitle(title);
|
||||
link.setHref(href);
|
||||
return link;
|
||||
}
|
||||
|
||||
protected static void setLink(final Entity entity, final String navigationPropertyName, final Entity target) {
|
||||
Link link = entity.getNavigationLink(navigationPropertyName);
|
||||
if (link == null) {
|
||||
link = new Link();
|
||||
link.setRel("http://docs.oasis-open.org/odata/ns/related/"+navigationPropertyName);
|
||||
link.setType(Constants.ENTITY_NAVIGATION_LINK_TYPE);
|
||||
link.setTitle(navigationPropertyName);
|
||||
link.setHref(target.getId().toASCIIString());
|
||||
entity.getNavigationLinks().add(link);
|
||||
}
|
||||
link.setInlineEntity(target);
|
||||
|
@ -1131,14 +1232,42 @@ public class DataCreator {
|
|||
Link link = entity.getNavigationLink(navigationPropertyName);
|
||||
if (link == null) {
|
||||
link = new Link();
|
||||
link.setRel("http://docs.oasis-open.org/odata/ns/related/"+navigationPropertyName);
|
||||
link.setType(Constants.ENTITY_SET_NAVIGATION_LINK_TYPE);
|
||||
link.setTitle(navigationPropertyName);
|
||||
EntityCollection target = new EntityCollection();
|
||||
target.getEntities().addAll(Arrays.asList(targets));
|
||||
link.setInlineEntitySet(target);
|
||||
link.setHref(entity.getId().toASCIIString()+"/"+navigationPropertyName);
|
||||
entity.getNavigationLinks().add(link);
|
||||
} else {
|
||||
link.getInlineEntitySet().getEntities().addAll(Arrays.asList(targets));
|
||||
}
|
||||
}
|
||||
|
||||
protected static void createEntityId (String esName, EntityCollection entities, List<EdmKeyPropertyRef> keys) {
|
||||
for (Entity entity:entities.getEntities()) {
|
||||
createEntityId(esName, entity, keys);
|
||||
}
|
||||
}
|
||||
protected static void createEntityId (String esName, Entity entity, List<EdmKeyPropertyRef> keys) {
|
||||
try {
|
||||
if(keys.size() == 1) {
|
||||
entity.setId(URI.create(esName+"("+entity.getProperty(keys.get(0).getName()).asPrimitive()+")"));
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(esName).append("(");
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
if (i != 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(keys.get(i)).append("=").append(entity.getProperty(keys.get(i).getName()).asPrimitive());
|
||||
}
|
||||
sb.append(")");
|
||||
entity.setId(URI.create(sb.toString()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
entity.setId(URI.create("id"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -63,12 +63,9 @@ public class DataProvider {
|
|||
private Edm edm;
|
||||
private OData odata;
|
||||
|
||||
public DataProvider() {
|
||||
data = new DataCreator().getData();
|
||||
}
|
||||
|
||||
public void setEdm(final Edm edm) {
|
||||
public DataProvider(final Edm edm) {
|
||||
this.edm = edm;
|
||||
data = new DataCreator(edm).getData();
|
||||
}
|
||||
|
||||
public void setOData(final OData odata) {
|
||||
|
@ -153,6 +150,7 @@ public class DataProvider {
|
|||
}
|
||||
|
||||
createProperties(edmEntityType, newEntity.getProperties());
|
||||
DataCreator.createEntityId(edmEntitySet.getName(), newEntity, edmEntityType.getKeyPropertyRefs());
|
||||
entities.add(newEntity);
|
||||
|
||||
return newEntity;
|
||||
|
|
|
@ -139,11 +139,13 @@ public class RequestValidator {
|
|||
|
||||
if (edmProperty.isCollection()) {
|
||||
final EntityCollection inlineEntitySet = navigationLink.getInlineEntitySet();
|
||||
if (!isInsert && inlineEntitySet.getEntities().size() > 0) {
|
||||
throw new DataProvider.DataProviderException("Deep update is not allowed", HttpStatusCode.BAD_REQUEST);
|
||||
} else {
|
||||
for (final Entity entity : navigationLink.getInlineEntitySet().getEntities()) {
|
||||
validate(edmBindingTarget, entity);
|
||||
if (inlineEntitySet != null) {
|
||||
if (!isInsert && inlineEntitySet.getEntities().size() > 0) {
|
||||
throw new DataProvider.DataProviderException("Deep update is not allowed", HttpStatusCode.BAD_REQUEST);
|
||||
} else {
|
||||
for (final Entity entity : navigationLink.getInlineEntitySet().getEntities()) {
|
||||
validate(edmBindingTarget, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -147,7 +147,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
checkRequestFormat(requestFormat);
|
||||
|
||||
//
|
||||
if(odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasRespondAsync()) {
|
||||
if (odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasRespondAsync()) {
|
||||
TechnicalAsyncService asyncService = TechnicalAsyncService.getInstance();
|
||||
TechnicalEntityProcessor processor = new TechnicalEntityProcessor(dataProvider, serviceMetadata);
|
||||
processor.init(odata, serviceMetadata);
|
||||
|
@ -161,7 +161,6 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
}
|
||||
//
|
||||
|
||||
|
||||
final UriResourceEntitySet resourceEntitySet = (UriResourceEntitySet) uriInfo.getUriResourceParts().get(0);
|
||||
final EdmEntitySet edmEntitySet = resourceEntitySet.getEntitySet();
|
||||
final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
|
||||
|
@ -173,7 +172,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
dataProvider.setMedia(entity, odata.createFixedFormatDeserializer().binary(request.getBody()),
|
||||
requestFormat.toContentTypeString());
|
||||
} else {
|
||||
final DeserializerResult deserializerResult =
|
||||
final DeserializerResult deserializerResult =
|
||||
odata.createDeserializer(requestFormat).entity(request.getBody(), edmEntityType);
|
||||
new RequestValidator(dataProvider, request.getRawBaseUri())
|
||||
.validate(edmEntitySet, deserializerResult.getEntity());
|
||||
|
@ -188,7 +187,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
|
||||
if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
|
||||
response.setContent(serializeEntity(request, entity, edmEntitySet, edmEntityType, responseFormat, expand, null)
|
||||
.getContent());
|
||||
.getContent());
|
||||
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
|
||||
response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
|
||||
} else {
|
||||
|
@ -238,13 +237,13 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
request.getRawBaseUri()).validate(edmEntitySet, changedEntity);
|
||||
|
||||
dataProvider.update(request.getRawBaseUri(), edmEntitySet, entity, changedEntity,
|
||||
request.getMethod() == HttpMethod.PATCH, false);
|
||||
request.getMethod() == HttpMethod.PATCH, false);
|
||||
|
||||
final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
|
||||
if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
|
||||
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
|
||||
response.setContent(serializeEntity(request, entity, edmEntitySet, edmEntityType, responseFormat)
|
||||
.getContent());
|
||||
.getContent());
|
||||
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
|
||||
} else {
|
||||
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
|
||||
|
@ -271,12 +270,12 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
request.getHeaders(HttpHeader.IF_NONE_MATCH));
|
||||
checkRequestFormat(requestFormat);
|
||||
dataProvider.setMedia(entity, odata.createFixedFormatDeserializer().binary(request.getBody()),
|
||||
requestFormat.toContentTypeString());
|
||||
requestFormat.toContentTypeString());
|
||||
|
||||
final Return returnPreference = odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).getReturn();
|
||||
if (returnPreference == null || returnPreference == Return.REPRESENTATION) {
|
||||
response.setContent(serializeEntity(request, entity, edmEntitySet, edmEntityType, responseFormat)
|
||||
.getContent());
|
||||
.getContent());
|
||||
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
|
||||
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
|
||||
} else {
|
||||
|
@ -360,7 +359,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
final UriResourceNavigation navigationProperty = getLastNavigation(uriInfo);
|
||||
ensureNavigationPropertyNotNull(navigationProperty);
|
||||
dataProvider.createReference(entity, navigationProperty.getProperty(), references.getEntityReferences().get(0),
|
||||
request.getRawBaseUri());
|
||||
request.getRawBaseUri());
|
||||
|
||||
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
|
||||
}
|
||||
|
@ -371,7 +370,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
|
||||
final UriResourceNavigation lastNavigation = getLastNavigation(uriInfo);
|
||||
final IdOption idOption = uriInfo.getIdOption();
|
||||
|
||||
|
||||
ensureNavigationPropertyNotNull(lastNavigation);
|
||||
if (lastNavigation.isCollection() && idOption == null) {
|
||||
throw new ODataApplicationException("Id system query option must be provided",
|
||||
|
@ -385,17 +384,17 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
|
||||
final Entity entity = readEntity(uriInfo, true);
|
||||
dataProvider.deleteReference(entity,
|
||||
lastNavigation.getProperty(),
|
||||
(uriInfo.getIdOption() != null) ? uriInfo.getIdOption().getValue() : null,
|
||||
request.getRawBaseUri());
|
||||
lastNavigation.getProperty(),
|
||||
(uriInfo.getIdOption() != null) ? uriInfo.getIdOption().getValue() : null,
|
||||
request.getRawBaseUri());
|
||||
|
||||
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readReferenceCollection(final ODataRequest request, final ODataResponse response,
|
||||
final UriInfo uriInfo, final ContentType requestedContentType)
|
||||
throws ODataApplicationException, ODataLibraryException {
|
||||
final UriInfo uriInfo, final ContentType requestedContentType)
|
||||
throws ODataApplicationException, ODataLibraryException {
|
||||
readEntityCollection(request, response, uriInfo, requestedContentType, true);
|
||||
}
|
||||
|
||||
|
@ -403,7 +402,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
final ContentType requestedFormat, final boolean isReference)
|
||||
throws ODataApplicationException, ODataLibraryException {
|
||||
//
|
||||
if(odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasRespondAsync()) {
|
||||
if (odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasRespondAsync()) {
|
||||
TechnicalAsyncService asyncService = TechnicalAsyncService.getInstance();
|
||||
TechnicalEntityProcessor processor = new TechnicalEntityProcessor(dataProvider, serviceMetadata);
|
||||
processor.init(odata, serviceMetadata);
|
||||
|
@ -455,7 +454,7 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
final UriInfo uriInfo, final ContentType requestedContentType, final boolean isReference)
|
||||
throws ODataApplicationException, ODataLibraryException {
|
||||
//
|
||||
if(odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasRespondAsync()) {
|
||||
if (odata.createPreferences(request.getHeaders(HttpHeader.PREFER)).hasRespondAsync()) {
|
||||
TechnicalAsyncService asyncService = TechnicalAsyncService.getInstance();
|
||||
TechnicalEntityProcessor processor = new TechnicalEntityProcessor(dataProvider, serviceMetadata);
|
||||
processor.init(odata, serviceMetadata);
|
||||
|
@ -514,12 +513,12 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
expandHandler.applyExpandQueryOptions(entitySetSerialization, edmEntitySet, expand);
|
||||
final CountOption countOption = uriInfo.getCountOption();
|
||||
|
||||
final String id = request.getRawBaseUri() + edmEntitySet.getName();
|
||||
// Serialize
|
||||
final SerializerResult serializerResult = (isReference) ?
|
||||
final SerializerResult serializerResult = (isReference) ?
|
||||
serializeReferenceCollection(entitySetSerialization, edmEntitySet, requestedContentType, countOption) :
|
||||
serializeEntityCollection(request, entitySetSerialization, edmEntitySet, edmEntityType, requestedContentType,
|
||||
expand, select, countOption);
|
||||
|
||||
expand, select, countOption, id);
|
||||
response.setContent(serializerResult.getContent());
|
||||
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
|
||||
response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
|
||||
|
@ -530,70 +529,69 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
}
|
||||
|
||||
private SerializerResult serializeEntityCollection(final ODataRequest request, final EntityCollection
|
||||
entityCollection,
|
||||
final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType, final ContentType requestedFormat,
|
||||
final ExpandOption expand, final SelectOption select, final CountOption countOption)
|
||||
throws ODataLibraryException {
|
||||
entityCollection, final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
|
||||
final ContentType requestedFormat, final ExpandOption expand, final SelectOption select,
|
||||
final CountOption countOption, String id) throws ODataLibraryException {
|
||||
|
||||
return odata.createSerializer(requestedFormat).entityCollection(
|
||||
serviceMetadata,
|
||||
edmEntityType,
|
||||
entityCollection,
|
||||
EntityCollectionSerializerOptions.with()
|
||||
.contextURL(isODataMetadataNone(requestedFormat) ? null :
|
||||
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, false, expand,
|
||||
select))
|
||||
.count(countOption)
|
||||
.expand(expand).select(select)
|
||||
.build());
|
||||
serviceMetadata,
|
||||
edmEntityType,
|
||||
entityCollection,
|
||||
EntityCollectionSerializerOptions.with()
|
||||
.contextURL(isODataMetadataNone(requestedFormat) ? null :
|
||||
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, false, expand, select))
|
||||
.count(countOption)
|
||||
.expand(expand).select(select)
|
||||
.setId(id)
|
||||
.build());
|
||||
}
|
||||
|
||||
private SerializerResult serializeReferenceCollection(final EntityCollection entityCollection,
|
||||
final EdmEntitySet edmEntitySet, final ContentType requestedFormat, final CountOption countOption)
|
||||
throws ODataLibraryException {
|
||||
private SerializerResult serializeReferenceCollection(final EntityCollection entityCollection,
|
||||
final EdmEntitySet edmEntitySet, final ContentType requestedFormat, final CountOption countOption)
|
||||
throws ODataLibraryException {
|
||||
|
||||
return odata.createSerializer(requestedFormat)
|
||||
.referenceCollection(serviceMetadata, edmEntitySet, entityCollection,
|
||||
ReferenceCollectionSerializerOptions.with()
|
||||
.contextURL(ContextURL.with().asCollection().suffix(Suffix.REFERENCE).build())
|
||||
.count(countOption).build());
|
||||
ReferenceCollectionSerializerOptions.with()
|
||||
.contextURL(ContextURL.with().asCollection().suffix(Suffix.REFERENCE).build())
|
||||
.count(countOption).build());
|
||||
}
|
||||
|
||||
private SerializerResult serializeReference(final Entity entity, final EdmEntitySet edmEntitySet,
|
||||
final ContentType requestedFormat) throws ODataLibraryException {
|
||||
return odata.createSerializer(requestedFormat)
|
||||
.reference(serviceMetadata, edmEntitySet, entity, ReferenceSerializerOptions.with()
|
||||
.contextURL(ContextURL.with().suffix(Suffix.REFERENCE).build()).build());
|
||||
|
||||
.contextURL(ContextURL.with().suffix(Suffix.REFERENCE).build()).build());
|
||||
|
||||
}
|
||||
|
||||
private SerializerResult serializeEntity(final ODataRequest request, final Entity entity,
|
||||
final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
|
||||
final ContentType requestedFormat) throws ODataLibraryException {
|
||||
final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
|
||||
final ContentType requestedFormat) throws ODataLibraryException {
|
||||
return serializeEntity(request, entity, edmEntitySet, edmEntityType, requestedFormat, null, null);
|
||||
}
|
||||
|
||||
private SerializerResult serializeEntity(final ODataRequest request, final Entity entity,
|
||||
final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
|
||||
final ContentType requestedFormat,
|
||||
final ExpandOption expand, final SelectOption select)
|
||||
throws ODataLibraryException {
|
||||
final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
|
||||
final ContentType requestedFormat,
|
||||
final ExpandOption expand, final SelectOption select)
|
||||
throws ODataLibraryException {
|
||||
|
||||
ContextURL contextUrl = isODataMetadataNone(requestedFormat) ? null :
|
||||
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, true, expand, null);
|
||||
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, true, expand, null);
|
||||
return odata.createSerializer(requestedFormat).entity(
|
||||
serviceMetadata,
|
||||
edmEntityType,
|
||||
entity,
|
||||
EntitySerializerOptions.with()
|
||||
.contextURL(contextUrl)
|
||||
.expand(expand).select(select)
|
||||
.build());
|
||||
serviceMetadata,
|
||||
edmEntityType,
|
||||
entity,
|
||||
EntitySerializerOptions.with()
|
||||
.contextURL(contextUrl)
|
||||
.expand(expand).select(select)
|
||||
.build());
|
||||
}
|
||||
|
||||
private ContextURL getContextUrl(String rawODataPath, final EdmEntitySet entitySet, final EdmEntityType entityType,
|
||||
final boolean isSingleEntity, final ExpandOption expand, final SelectOption select)
|
||||
throws ODataLibraryException {
|
||||
final boolean isSingleEntity, final ExpandOption expand, final SelectOption select)
|
||||
throws ODataLibraryException {
|
||||
//
|
||||
//
|
||||
Builder builder = ContextURL.with().oDataPath(rawODataPath);
|
||||
|
@ -605,10 +603,10 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
|
|||
.suffix(isSingleEntity && entitySet != null ? Suffix.ENTITY : null);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
private void ensureNavigationPropertyNotNull(final UriResourceNavigation navigationProperty)
|
||||
throws ODataApplicationException {
|
||||
if(navigationProperty == null) {
|
||||
if (navigationProperty == null) {
|
||||
throw new ODataApplicationException("Missing navigation segment", HttpStatusCode.BAD_REQUEST.getStatusCode(),
|
||||
Locale.ROOT);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ public abstract class TechnicalProcessor implements Processor {
|
|||
this.odata = odata;
|
||||
this.serviceMetadata = serviceMetadata;
|
||||
dataProvider.setOData(odata);
|
||||
dataProvider.setEdm(serviceMetadata.getEdm());
|
||||
}
|
||||
|
||||
protected EdmEntitySet getEdmEntitySet(final UriInfoResource uriInfo) throws ODataApplicationException {
|
||||
|
|
|
@ -202,7 +202,7 @@ public class ExpandSystemQueryOptionHandler {
|
|||
newLink.setTitle(link.getTitle());
|
||||
newLink.setType(link.getType());
|
||||
newLink.setRel(link.getRel());
|
||||
|
||||
newLink.setHref(link.getHref());
|
||||
return newLink;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class DataProviderTest {
|
|||
|
||||
@Test
|
||||
public void esAllPrimEntity() throws Exception {
|
||||
final DataProvider dataProvider = new DataProvider();
|
||||
final DataProvider dataProvider = new DataProvider(edm);
|
||||
final Entity entity = dataProvider.readAll(esAllPrim).getEntities().get(2);
|
||||
Assert.assertEquals(16, entity.getProperties().size());
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class DataProviderTest {
|
|||
|
||||
@Test
|
||||
public void esAllKeyEntity() throws Exception {
|
||||
final DataProvider dataProvider = new DataProvider();
|
||||
final DataProvider dataProvider = new DataProvider(edm);
|
||||
final Entity entity = dataProvider.readAll(esAllKey).getEntities().get(0);
|
||||
Assert.assertEquals(13, entity.getProperties().size());
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class DataProviderTest {
|
|||
|
||||
@Test
|
||||
public void esAllPrim() throws Exception {
|
||||
final DataProvider data = new DataProvider();
|
||||
final DataProvider data = new DataProvider(edm);
|
||||
EntityCollection outSet = data.readAll(esAllPrim);
|
||||
|
||||
Assert.assertEquals(3, outSet.getEntities().size());
|
||||
|
@ -107,7 +107,8 @@ public class DataProviderTest {
|
|||
|
||||
@Test
|
||||
public void esCollAllPrim() throws Exception {
|
||||
EntityCollection outSet = new DataProvider().readAll(esCollAllPrim);
|
||||
final DataProvider dataProvider = new DataProvider(edm);
|
||||
EntityCollection outSet = dataProvider.readAll(esCollAllPrim);
|
||||
|
||||
Assert.assertEquals(3, outSet.getEntities().size());
|
||||
Assert.assertEquals(17, outSet.getEntities().get(0).getProperties().size());
|
||||
|
@ -120,7 +121,9 @@ public class DataProviderTest {
|
|||
|
||||
@Test
|
||||
public void esCompAllPrim() throws Exception {
|
||||
EntityCollection outSet = new DataProvider().readAll(esCompAllPrim);
|
||||
final DataProvider dataProvider = new DataProvider(edm);
|
||||
|
||||
EntityCollection outSet = dataProvider.readAll(esCompAllPrim);
|
||||
|
||||
Assert.assertEquals(4, outSet.getEntities().size());
|
||||
Assert.assertEquals(2, outSet.getEntities().get(0).getProperties().size());
|
||||
|
@ -133,7 +136,9 @@ public class DataProviderTest {
|
|||
|
||||
@Test
|
||||
public void esMixPrimCollComp() throws Exception {
|
||||
EntityCollection outSet = new DataProvider().readAll(esMixPrimCollComp);
|
||||
final DataProvider dataProvider = new DataProvider(edm);
|
||||
|
||||
EntityCollection outSet = dataProvider.readAll(esMixPrimCollComp);
|
||||
|
||||
Assert.assertEquals(3, outSet.getEntities().size());
|
||||
Assert.assertEquals(4, outSet.getEntities().get(0).getProperties().size());
|
||||
|
@ -156,7 +161,8 @@ public class DataProviderTest {
|
|||
|
||||
@Test
|
||||
public void esMedia() throws Exception {
|
||||
DataProvider dataProvider = new DataProvider();
|
||||
DataProvider dataProvider = new DataProvider(edm);
|
||||
|
||||
Entity entity = dataProvider.read(esMedia, Arrays.asList(mockParameter("PropertyInt16", "3")));
|
||||
Assert.assertNotNull(dataProvider.readMedia(entity));
|
||||
dataProvider.delete(esMedia, entity);
|
||||
|
|
|
@ -67,6 +67,11 @@
|
|||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xmlunit</groupId>
|
||||
<artifactId>xmlunit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ODataJsonSerializerTest {
|
|||
private static final ServiceMetadata metadata = new ServiceMetadataImpl(
|
||||
new EdmTechProvider(), Collections.<EdmxReference> emptyList(), new MetadataETagSupport("W/\"metadataETag\""));
|
||||
private static final EdmEntityContainer entityContainer = metadata.getEdm().getEntityContainer();
|
||||
private final DataProvider data = new DataProvider();
|
||||
private final DataProvider data = new DataProvider(metadata.getEdm());
|
||||
private final ODataSerializer serializer = new ODataJsonSerializer(ContentType.JSON);
|
||||
private final ODataSerializer serializerNoMetadata = new ODataJsonSerializer(ContentType.JSON_NO_METADATA);
|
||||
private final ODataSerializer serializerIEEECompatible =
|
||||
|
@ -341,7 +341,9 @@ public class ODataJsonSerializerTest {
|
|||
.build()).getContent());
|
||||
final String expectedResult = "{\"@odata.context\":\"$metadata#ESMedia/$entity\","
|
||||
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
|
||||
+ "\"@odata.mediaEtag\":\"W/\\\"1\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\","
|
||||
+ "\"@odata.mediaEtag\":\"W/\\\"1\\\"\","
|
||||
+ "\"@odata.mediaContentType\":\"image/svg+xml\","
|
||||
+ "\"@odata.mediaEditLink\":\"ESMedia(1)/$value\","
|
||||
+ "\"PropertyInt16\":1}";
|
||||
Assert.assertEquals(expectedResult, resultString);
|
||||
}
|
||||
|
@ -357,10 +359,14 @@ public class ODataJsonSerializerTest {
|
|||
final String expectedResult = "{\"@odata.context\":\"$metadata#ESMedia\","
|
||||
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
|
||||
+ "\"value\":["
|
||||
+ "{\"@odata.mediaEtag\":\"W/\\\"1\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\",\"PropertyInt16\":1},"
|
||||
+ "{\"@odata.mediaEtag\":\"W/\\\"2\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\",\"PropertyInt16\":2},"
|
||||
+ "{\"@odata.mediaEtag\":\"W/\\\"3\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\",\"PropertyInt16\":3},"
|
||||
+ "{\"@odata.mediaEtag\":\"W/\\\"4\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\",\"PropertyInt16\":4}]}";
|
||||
+ "{\"@odata.mediaEtag\":\"W/\\\"1\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\","
|
||||
+ "\"@odata.mediaEditLink\":\"ESMedia(1)/$value\",\"PropertyInt16\":1},"
|
||||
+ "{\"@odata.mediaEtag\":\"W/\\\"2\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\","
|
||||
+ "\"@odata.mediaEditLink\":\"ESMedia(2)/$value\",\"PropertyInt16\":2},"
|
||||
+ "{\"@odata.mediaEtag\":\"W/\\\"3\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\","
|
||||
+ "\"@odata.mediaEditLink\":\"ESMedia(3)/$value\",\"PropertyInt16\":3},"
|
||||
+ "{\"@odata.mediaEtag\":\"W/\\\"4\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\","
|
||||
+ "\"@odata.mediaEditLink\":\"ESMedia(4)/$value\",\"PropertyInt16\":4}]}";
|
||||
Assert.assertEquals(expectedResult, resultString);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,630 @@
|
|||
/*
|
||||
* 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.server.core.serializer.xml;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.Link;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmComplexType;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.EdmProperty;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
|
||||
import org.apache.olingo.commons.core.edm.EdmComplexTypeImpl;
|
||||
import org.apache.olingo.commons.core.edm.EdmPropertyImpl;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmBinary;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmByte;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmDate;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmGuid;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmInt16;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmSByte;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmSingle;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmTimeOfDay;
|
||||
import org.apache.olingo.server.api.ServiceMetadata;
|
||||
import org.apache.olingo.server.api.deserializer.ODataDeserializer;
|
||||
import org.apache.olingo.server.api.edmx.EdmxReference;
|
||||
import org.apache.olingo.server.core.ServiceMetadataImpl;
|
||||
import org.apache.olingo.server.core.deserializer.xml.ODataXmlDeserializer;
|
||||
import org.apache.olingo.server.tecsvc.MetadataETagSupport;
|
||||
import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
|
||||
import org.custommonkey.xmlunit.XMLUnit;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
public class ODataXmlDeserializerTest {
|
||||
|
||||
private static final ServiceMetadata metadata = new ServiceMetadataImpl(
|
||||
new EdmTechProvider(), Collections.<EdmxReference> emptyList(), new MetadataETagSupport("WmetadataETag"));
|
||||
private static final EdmEntityContainer entityContainer = metadata.getEdm().getEntityContainer();
|
||||
private final ODataDeserializer serializer = new ODataXmlDeserializer();
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
XMLUnit.setIgnoreComments(true);
|
||||
XMLUnit.setIgnoreAttributeOrder(true);
|
||||
XMLUnit.setIgnoreWhitespace(true);
|
||||
XMLUnit.setNormalizeWhitespace(true);
|
||||
XMLUnit.setCompareUnmatched(false);
|
||||
}
|
||||
|
||||
private Object edmInt16(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmInt16.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmInt16.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmInt32(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmInt32.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmInt32.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmInt64(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmInt64.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmInt64.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmSingle(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmSingle.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmSingle.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmDouble(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmDouble.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmDouble.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmSByte(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmSByte.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmSByte.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmByte(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmByte.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmByte.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmDecimal(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmDecimal.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmDecimal.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmBinary(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmBinary.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmBinary.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmDate(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmDate.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmDate.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmDateTimeOffset(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmDateTimeOffset.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmDateTimeOffset.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmDuration(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmDuration.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmDuration.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmGUID(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmGuid.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmGuid.getInstance().getDefaultType());
|
||||
}
|
||||
private Object edmTimeOfDay(String value) throws EdmPrimitiveTypeException {
|
||||
return EdmTimeOfDay.getInstance().valueOfString(value, true, 10, 10, 10, true,
|
||||
EdmTimeOfDay.getInstance().getDefaultType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entitySimple() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||
|
||||
String payload = "<?xml version='1.0' encoding='UTF-8'?>\n" +
|
||||
"<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\"\n" +
|
||||
" xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
|
||||
" xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\"> " +
|
||||
" <atom:link\n" +
|
||||
" rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoPrimMany\"\n" +
|
||||
" type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoPrimMany\"\n" +
|
||||
" href=\"id\" />\n" +
|
||||
" <atom:link\n" +
|
||||
" rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoPrimOne\"\n" +
|
||||
" type=\"application/atom+xml;type=entry\" title=\"NavPropertyETTwoPrimOne\"\n" +
|
||||
" href=\"id\" />\n" +
|
||||
" <atom:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\"\n" +
|
||||
" term=\"#olingo.odata.test1.ETAllPrim\" />\n" +
|
||||
" <atom:content type=\"application/xml\">\n" +
|
||||
" <metadata:properties>\n" +
|
||||
" <data:PropertyInt16>32767</data:PropertyInt16>\n" +
|
||||
" <data:PropertyString>First Resource - positive values</data:PropertyString>\n" +
|
||||
" <data:PropertyBoolean>true</data:PropertyBoolean>\n" +
|
||||
" <data:PropertyByte>255</data:PropertyByte>\n" +
|
||||
" <data:PropertySByte>127</data:PropertySByte>\n" +
|
||||
" <data:PropertyInt32>2147483647</data:PropertyInt32>\n" +
|
||||
" <data:PropertyInt64>9223372036854775807</data:PropertyInt64>\n" +
|
||||
" <data:PropertySingle>1.79E20</data:PropertySingle>\n" +
|
||||
" <data:PropertyDouble>-1.79E19</data:PropertyDouble>\n" +
|
||||
" <data:PropertyDecimal>34</data:PropertyDecimal>\n" +
|
||||
" <data:PropertyBinary>ASNFZ4mrze8=</data:PropertyBinary>\n" +
|
||||
" <data:PropertyDate>2012-12-03</data:PropertyDate>\n" +
|
||||
" <data:PropertyDateTimeOffset>2012-12-03T07:16:23Z</data:PropertyDateTimeOffset>\n" +
|
||||
" <data:PropertyDuration>PT6S</data:PropertyDuration>\n" +
|
||||
" <data:PropertyGuid>01234567-89ab-cdef-0123-456789abcdef</data:PropertyGuid>\n" +
|
||||
" <data:PropertyTimeOfDay>03:26:05</data:PropertyTimeOfDay>\n" +
|
||||
" </metadata:properties>\n" +
|
||||
" </atom:content>\n" +
|
||||
"</atom:entry>\n";
|
||||
|
||||
Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()),
|
||||
edmEntitySet.getEntityType()).getEntity();
|
||||
|
||||
Assert.assertEquals(16, result.getProperties().size());
|
||||
Assert.assertEquals(2, result.getNavigationBindings().size());
|
||||
|
||||
Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
|
||||
Assert.assertEquals("First Resource - positive values", result.getProperty("PropertyString").asPrimitive());
|
||||
Assert.assertEquals(edmByte("255"), result.getProperty("PropertyByte").asPrimitive());
|
||||
Assert.assertEquals(edmSByte("127"), result.getProperty("PropertySByte").asPrimitive());
|
||||
Assert.assertEquals(edmInt32("2147483647"), result.getProperty("PropertyInt32").asPrimitive());
|
||||
Assert.assertEquals(edmInt64("9223372036854775807"), result.getProperty("PropertyInt64").asPrimitive());
|
||||
Assert.assertEquals(edmSingle("1.79E20"), result.getProperty("PropertySingle").asPrimitive());
|
||||
Assert.assertEquals(edmDouble("-1.79E19"), result.getProperty("PropertyDouble").asPrimitive());
|
||||
Assert.assertEquals(edmDecimal("34"), result.getProperty("PropertyDecimal").asPrimitive());
|
||||
// Assert.assertEquals(edmBinary("ASNFZ4mrze8="), result.getProperty("PropertyBinary").asPrimitive());
|
||||
Assert.assertEquals(edmDate("2012-12-03"), result.getProperty("PropertyDate").asPrimitive());
|
||||
Assert.assertEquals(edmDateTimeOffset("2012-12-03T07:16:23Z"), result.getProperty("PropertyDateTimeOffset")
|
||||
.asPrimitive());
|
||||
Assert.assertEquals(edmDuration("PT6S"), result.getProperty("PropertyDuration")
|
||||
.asPrimitive());
|
||||
Assert.assertEquals(edmGUID("01234567-89ab-cdef-0123-456789abcdef"), result.getProperty("PropertyGuid")
|
||||
.asPrimitive());
|
||||
Assert.assertEquals(edmTimeOfDay("03:26:05"), result.getProperty("PropertyTimeOfDay").asPrimitive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entitySimpleWithTypes() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||
|
||||
String payload = "<?xml version='1.0' encoding='UTF-8'?>\n" +
|
||||
"<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\"\n" +
|
||||
" xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
|
||||
" xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\"> " +
|
||||
" <atom:link\n" +
|
||||
" rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoPrimMany\"\n" +
|
||||
" type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoPrimMany\"\n" +
|
||||
" href=\"id\" />\n" +
|
||||
" <atom:link\n" +
|
||||
" rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoPrimOne\"\n" +
|
||||
" type=\"application/atom+xml;type=entry\" title=\"NavPropertyETTwoPrimOne\"\n" +
|
||||
" href=\"id\" />\n" +
|
||||
" <atom:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\"\n" +
|
||||
" term=\"#olingo.odata.test1.ETAllPrim\" />\n" +
|
||||
" <atom:content type=\"application/xml\">\n" +
|
||||
" <metadata:properties>\n" +
|
||||
" <data:PropertyInt16 metadata:type=\"Int16\">32767</data:PropertyInt16>\n" +
|
||||
" <data:PropertyString>First Resource - positive values</data:PropertyString>\n" +
|
||||
" <data:PropertyBoolean metadata:type=\"Boolean\">true</data:PropertyBoolean>\n" +
|
||||
" <data:PropertyByte metadata:type=\"Byte\">255</data:PropertyByte>\n" +
|
||||
" <data:PropertySByte metadata:type=\"SByte\">127</data:PropertySByte>\n" +
|
||||
" <data:PropertyInt32 metadata:type=\"Int32\">2147483647</data:PropertyInt32>\n" +
|
||||
" <data:PropertyInt64 metadata:type=\"Int64\">9223372036854775807</data:PropertyInt64>\n" +
|
||||
" <data:PropertySingle metadata:type=\"Single\">1.79E20</data:PropertySingle>\n" +
|
||||
" <data:PropertyDouble metadata:type=\"Double\">-1.79E19</data:PropertyDouble>\n" +
|
||||
" <data:PropertyDecimal metadata:type=\"Decimal\">34</data:PropertyDecimal>\n" +
|
||||
" <data:PropertyBinary metadata:type=\"Binary\">ASNFZ4mrze8=</data:PropertyBinary>\n" +
|
||||
" <data:PropertyDate metadata:type=\"Date\">2012-12-03</data:PropertyDate>\n" +
|
||||
" <data:PropertyDateTimeOffset metadata:type=\"DateTimeOffset\">2012-12-03T07:16:23Z"
|
||||
+ "</data:PropertyDateTimeOffset>\n" +
|
||||
" <data:PropertyDuration metadata:type=\"Duration\">PT6S</data:PropertyDuration>\n" +
|
||||
" <data:PropertyGuid metadata:type=\"GUID\">01234567-89ab-cdef-0123-456789abcdef"
|
||||
+ "</data:PropertyGuid>\n" +
|
||||
" <data:PropertyTimeOfDay metadata:type=\"TimeOfDay\">03:26:05</data:PropertyTimeOfDay>\n" +
|
||||
" </metadata:properties>\n" +
|
||||
" </atom:content>\n" +
|
||||
"</atom:entry>\n";
|
||||
|
||||
Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()),
|
||||
edmEntitySet.getEntityType()).getEntity();
|
||||
|
||||
Assert.assertEquals(16, result.getProperties().size());
|
||||
Assert.assertEquals(2, result.getNavigationBindings().size());
|
||||
|
||||
Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
|
||||
Assert.assertEquals("First Resource - positive values", result.getProperty("PropertyString").asPrimitive());
|
||||
Assert.assertEquals(edmByte("255"), result.getProperty("PropertyByte").asPrimitive());
|
||||
Assert.assertEquals(edmSByte("127"), result.getProperty("PropertySByte").asPrimitive());
|
||||
Assert.assertEquals(edmInt32("2147483647"), result.getProperty("PropertyInt32").asPrimitive());
|
||||
Assert.assertEquals(edmInt64("9223372036854775807"), result.getProperty("PropertyInt64").asPrimitive());
|
||||
Assert.assertEquals(edmSingle("1.79E20"), result.getProperty("PropertySingle").asPrimitive());
|
||||
Assert.assertEquals(edmDouble("-1.79E19"), result.getProperty("PropertyDouble").asPrimitive());
|
||||
Assert.assertEquals(edmDecimal("34"), result.getProperty("PropertyDecimal").asPrimitive());
|
||||
// Assert.assertEquals(edmBinary("ASNFZ4mrze8="), result.getProperty("PropertyBinary").asPrimitive());
|
||||
Assert.assertEquals(edmDate("2012-12-03"), result.getProperty("PropertyDate").asPrimitive());
|
||||
Assert.assertEquals(edmDateTimeOffset("2012-12-03T07:16:23Z"), result.getProperty("PropertyDateTimeOffset")
|
||||
.asPrimitive());
|
||||
Assert.assertEquals(edmDuration("PT6S"), result.getProperty("PropertyDuration")
|
||||
.asPrimitive());
|
||||
Assert.assertEquals(edmGUID("01234567-89ab-cdef-0123-456789abcdef"), result.getProperty("PropertyGuid")
|
||||
.asPrimitive());
|
||||
Assert.assertEquals(edmTimeOfDay("03:26:05"), result.getProperty("PropertyTimeOfDay").asPrimitive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityCompAllPrim() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompAllPrim");
|
||||
|
||||
String payload = "<?xml version='1.0' encoding='UTF-8'?>"
|
||||
+ "<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\" "
|
||||
+ "xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
|
||||
+ "xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
|
||||
+ "metadata:etag=\"W/"32767"\">"
|
||||
+ "<atom:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\" "
|
||||
+ "term=\"#olingo.odata.test1.ETCompAllPrim\"/>"
|
||||
+ "<atom:content type=\"application/xml\">"
|
||||
+ "<metadata:properties>"
|
||||
+ "<data:PropertyInt16>32767</data:PropertyInt16>"
|
||||
+ "<data:PropertyComp metadata:type=\"#olingo.odata.test1.CTAllPrim\">"
|
||||
+ "<data:PropertyString>First Resource - first</data:PropertyString>"
|
||||
+ "<data:PropertyBinary>ASNFZ4mrze8=</data:PropertyBinary>"
|
||||
+ "<data:PropertyBoolean>true</data:PropertyBoolean>"
|
||||
+ "<data:PropertyByte>255</data:PropertyByte>"
|
||||
+ "<data:PropertyDate>2012-10-03</data:PropertyDate>"
|
||||
+ "<data:PropertyDateTimeOffset>2012-10-03T07:16:23.1234567Z</data:PropertyDateTimeOffset>"
|
||||
+ "<data:PropertyDecimal>34.27</data:PropertyDecimal>"
|
||||
+ "<data:PropertySingle>1.79E20</data:PropertySingle>"
|
||||
+ "<data:PropertyDouble>-1.79E19</data:PropertyDouble>"
|
||||
+ "<data:PropertyDuration>PT6S</data:PropertyDuration>"
|
||||
+ "<data:PropertyGuid>01234567-89ab-cdef-0123-456789abcdef</data:PropertyGuid>"
|
||||
+ "<data:PropertyInt16>32767</data:PropertyInt16>"
|
||||
+ "<data:PropertyInt32>2147483647</data:PropertyInt32>"
|
||||
+ "<data:PropertyInt64>9223372036854775807</data:PropertyInt64>"
|
||||
+ "<data:PropertySByte>127</data:PropertySByte>"
|
||||
+ "<data:PropertyTimeOfDay>01:00:01</data:PropertyTimeOfDay>"
|
||||
+ "</data:PropertyComp>"
|
||||
+ "</metadata:properties>"
|
||||
+ "</atom:content>"
|
||||
+ "</atom:entry>";
|
||||
|
||||
Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()),
|
||||
edmEntitySet.getEntityType()).getEntity();
|
||||
|
||||
Assert.assertEquals("olingo.odata.test1.ETCompAllPrim",result.getType());
|
||||
|
||||
Assert.assertEquals(2, result.getProperties().size());
|
||||
Assert.assertEquals(0, result.getNavigationLinks().size());
|
||||
|
||||
Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
|
||||
|
||||
Assert.assertNotNull(result.getProperty("PropertyComp"));
|
||||
Property comp = result.getProperty("PropertyComp");
|
||||
Assert.assertEquals("olingo.odata.test1.CTAllPrim", comp.getType());
|
||||
ComplexValue cv = (ComplexValue)comp.getValue();
|
||||
|
||||
Assert.assertEquals(16, cv.getValue().size());
|
||||
|
||||
Assert.assertEquals(edmInt16("32767"), getCVProperty(cv, "PropertyInt16").asPrimitive());
|
||||
Assert.assertEquals("First Resource - first", getCVProperty(cv, "PropertyString").asPrimitive());
|
||||
Assert.assertEquals(edmByte("255"), getCVProperty(cv, "PropertyByte").asPrimitive());
|
||||
Assert.assertEquals(edmSByte("127"), getCVProperty(cv, "PropertySByte").asPrimitive());
|
||||
Assert.assertEquals(edmInt32("2147483647"), getCVProperty(cv, "PropertyInt32").asPrimitive());
|
||||
Assert.assertEquals(edmInt64("9223372036854775807"), getCVProperty(cv, "PropertyInt64").asPrimitive());
|
||||
}
|
||||
|
||||
private Property getCVProperty(ComplexValue cv, String name) {
|
||||
for (Property p:cv.getValue()) {
|
||||
if (p.getName().equals(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityMixPrimCollComp() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
|
||||
final String payload = "<?xml version='1.0' encoding='UTF-8'?>\n" +
|
||||
"<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\"\n" +
|
||||
" xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
|
||||
" xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" \n" +
|
||||
" metadata:metadata-etag=\"WmetadataETag\">\n" +
|
||||
" <atom:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\"\n" +
|
||||
" term=\"#olingo.odata.test1.ETMixPrimCollComp\" />\n" +
|
||||
" <atom:content type=\"application/xml\">\n" +
|
||||
" <metadata:properties>\n" +
|
||||
" <data:PropertyInt16>32767</data:PropertyInt16>\n" +
|
||||
" <data:CollPropertyString type=\"#Collection(String)\">\n" +
|
||||
" <metadata:element>Employee1@company.example</metadata:element>\n" +
|
||||
" <metadata:element>Employee2@company.example</metadata:element>\n" +
|
||||
" <metadata:element>Employee3@company.example</metadata:element>\n" +
|
||||
" </data:CollPropertyString>\n" +
|
||||
" <data:PropertyComp metadata:type=\"#olingo.odata.test1.CTTwoPrim\">\n" +
|
||||
" <data:PropertyInt16>111</data:PropertyInt16>\n" +
|
||||
" <data:PropertyString>TEST A</data:PropertyString>\n" +
|
||||
" </data:PropertyComp>\n" +
|
||||
" <data:CollPropertyComp metadata:type=\"#Collection(olingo.odata.test1.CTTwoPrim)\">\n" +
|
||||
" <metadata:element>\n" +
|
||||
" <data:PropertyInt16>123</data:PropertyInt16>\n" +
|
||||
" <data:PropertyString>TEST 1</data:PropertyString>\n" +
|
||||
" </metadata:element>\n" +
|
||||
" <metadata:element>\n" +
|
||||
" <data:PropertyInt16>456</data:PropertyInt16>\n" +
|
||||
" <data:PropertyString>TEST 2</data:PropertyString>\n" +
|
||||
" </metadata:element>\n" +
|
||||
" <metadata:element>\n" +
|
||||
" <data:PropertyInt16>789</data:PropertyInt16>\n" +
|
||||
" <data:PropertyString>TEST 3</data:PropertyString>\n" +
|
||||
" </metadata:element>\n" +
|
||||
" </data:CollPropertyComp>\n" +
|
||||
" </metadata:properties>\n" +
|
||||
" </atom:content>\n" +
|
||||
"</atom:entry>\n";
|
||||
|
||||
Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()),
|
||||
edmEntitySet.getEntityType()).getEntity();
|
||||
|
||||
Assert.assertEquals(4, result.getProperties().size());
|
||||
Assert.assertEquals(0, result.getNavigationLinks().size());
|
||||
|
||||
Assert.assertEquals(Arrays.asList("Employee1@company.example", "Employee2@company.example",
|
||||
"Employee3@company.example"), result.getProperty("CollPropertyString").getValue());
|
||||
|
||||
Property comp = result.getProperty("PropertyComp");
|
||||
Assert.assertEquals("olingo.odata.test1.CTTwoPrim", comp.getType());
|
||||
ComplexValue cv = (ComplexValue)comp.getValue();
|
||||
|
||||
Assert.assertEquals(2, cv.getValue().size());
|
||||
Assert.assertEquals(edmInt16("111"), getCVProperty(cv, "PropertyInt16").asPrimitive());
|
||||
Assert.assertEquals("TEST A", getCVProperty(cv, "PropertyString").asPrimitive());
|
||||
|
||||
comp = result.getProperty("CollPropertyComp");
|
||||
Assert.assertEquals("Collection(olingo.odata.test1.CTTwoPrim)", comp.getType());
|
||||
List<ComplexValue> properties = (List<ComplexValue>)comp.getValue();
|
||||
|
||||
Assert.assertEquals(3, properties.size());
|
||||
|
||||
Assert.assertEquals(edmInt16("123"), getCVProperty(properties.get(0), "PropertyInt16")
|
||||
.asPrimitive());
|
||||
Assert.assertEquals("TEST 1", getCVProperty(properties.get(0), "PropertyString")
|
||||
.asPrimitive());
|
||||
|
||||
Assert.assertEquals(edmInt16("789"), getCVProperty(properties.get(2), "PropertyInt16")
|
||||
.asPrimitive());
|
||||
Assert.assertEquals("TEST 3", getCVProperty(properties.get(2), "PropertyString")
|
||||
.asPrimitive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityWithNavigation() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
|
||||
|
||||
final String payload = "<?xml version='1.0' encoding='UTF-8'?>\n" +
|
||||
"<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\"\n" +
|
||||
" xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
|
||||
" xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\">" +
|
||||
" <atom:link\n" +
|
||||
" rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETAllPrimOne\"\n" +
|
||||
" type=\"application/atom+xml;type=entry\" title=\"NavPropertyETAllPrimOne\"\n" +
|
||||
" href=\"id\">\n" +
|
||||
" <metadata:inline>\n" +
|
||||
" <atom:entry>\n" +
|
||||
" <atom:link\n" +
|
||||
" rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoPrimMany\"\n" +
|
||||
" type=\"application/atom+xml;type=feed\" title=\"NavPropertyETTwoPrimMany\"\n" +
|
||||
" href=\"id\" />\n" +
|
||||
" <atom:link\n" +
|
||||
" rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETTwoPrimOne\"\n" +
|
||||
" type=\"application/atom+xml;type=entry\" title=\"NavPropertyETTwoPrimOne\"\n" +
|
||||
" href=\"id\" />\n" +
|
||||
" <atom:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\"\n" +
|
||||
" term=\"#olingo.odata.test1.ETAllPrim\" />\n" +
|
||||
" <atom:content type=\"application/xml\">\n" +
|
||||
" <metadata:properties>\n" +
|
||||
" <data:PropertyDate>2012-12-03</data:PropertyDate>\n" +
|
||||
" </metadata:properties>\n" +
|
||||
" </atom:content>\n" +
|
||||
" </atom:entry>\n" +
|
||||
" </metadata:inline>\n" +
|
||||
" </atom:link>\n" +
|
||||
" <atom:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\"\n" +
|
||||
" term=\"#olingo.odata.test1.ETTwoPrim\" />\n" +
|
||||
" <atom:content type=\"application/xml\">\n" +
|
||||
" <metadata:properties>\n" +
|
||||
" <data:PropertyInt16>32767</data:PropertyInt16>\n" +
|
||||
" <data:PropertyString>Test String4</data:PropertyString>\n" +
|
||||
" </metadata:properties>\n" +
|
||||
" </atom:content>\n" +
|
||||
"</atom:entry>\n" +
|
||||
"";
|
||||
|
||||
Entity result = serializer.entity(new ByteArrayInputStream(payload.getBytes()),
|
||||
edmEntitySet.getEntityType()).getEntity();
|
||||
|
||||
Assert.assertEquals(2, result.getProperties().size());
|
||||
Assert.assertEquals(1, result.getNavigationLinks().size());
|
||||
|
||||
Assert.assertEquals(edmInt16("32767"), result.getProperty("PropertyInt16").asPrimitive());
|
||||
Assert.assertEquals("Test String4", result.getProperty("PropertyString").asPrimitive());
|
||||
|
||||
Assert.assertEquals(1, result.getNavigationLinks().size());
|
||||
Link navLink = result.getNavigationLinks().get(0);
|
||||
Assert.assertEquals("http://docs.oasis-open.org/odata/ns/related/NavPropertyETAllPrimOne", navLink.getRel());
|
||||
Assert.assertEquals("id", navLink.getBindingLink());
|
||||
Assert.assertEquals("NavPropertyETAllPrimOne", navLink.getTitle());
|
||||
|
||||
Entity inline = navLink.getInlineEntity();
|
||||
Assert.assertEquals(1, inline.getProperties().size());
|
||||
Assert.assertEquals(2, inline.getNavigationBindings().size());
|
||||
Assert.assertEquals(edmDate("2012-12-03"), inline.getProperty("PropertyDate").asPrimitive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void primitiveProperty() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||
final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("PropertyInt16");
|
||||
|
||||
String payload = "<?xml version='1.0' encoding='UTF-8'?>"
|
||||
+ "<metadata:value xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\">"
|
||||
+ "234</metadata:value>";
|
||||
|
||||
Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
|
||||
Assert.assertEquals(edmInt16("234"), result.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void primitivePropertyNull() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
|
||||
final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("PropertyString");
|
||||
String payload = "<?xml version='1.0' encoding='UTF-8'?>"
|
||||
+ "<metadata:value xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\" "
|
||||
+ "metadata:null=\"true\"/>";
|
||||
|
||||
Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
|
||||
Assert.assertNull(result.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void primitiveCollectionProperty() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCollAllPrim");
|
||||
final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("CollPropertyString");
|
||||
String payload = "<?xml version='1.0' encoding='UTF-8'?>"
|
||||
+ "<metadata:value xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"> "
|
||||
+ "<metadata:element>Employee1@company.example</metadata:element>"
|
||||
+ "<metadata:element>Employee2@company.example</metadata:element>"
|
||||
+ "<metadata:element>Employee3@company.example</metadata:element>"
|
||||
+ "</metadata:value>";
|
||||
Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
|
||||
Assert.assertEquals(Arrays.asList("Employee1@company.example", "Employee2@company.example",
|
||||
"Employee3@company.example"), result.getValue());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void complexProperty() throws Exception {
|
||||
Edm edm = Mockito.mock(Edm.class);
|
||||
|
||||
CsdlProperty street = new CsdlProperty().setName("Street")
|
||||
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
|
||||
CsdlProperty city = new CsdlProperty().setName("City")
|
||||
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
|
||||
CsdlProperty region = new CsdlProperty().setName("Region")
|
||||
.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
|
||||
CsdlProperty postalcode = new CsdlProperty().setName("PostalCode")
|
||||
.setType(EdmPrimitiveTypeKind.Int64.getFullQualifiedName());
|
||||
|
||||
CsdlComplexType ct = new CsdlComplexType()
|
||||
.setName("Model.Address")
|
||||
.setProperties(Arrays.asList(street, city, region, postalcode));
|
||||
EdmComplexTypeImpl complexType = new EdmComplexTypeImpl(edm, new FullQualifiedName("Model.Address"), ct);
|
||||
|
||||
Mockito.stub(edm.getComplexType(new FullQualifiedName("Model.Address"))).toReturn(complexType);
|
||||
|
||||
CsdlProperty prop = new CsdlProperty();
|
||||
prop.setName("ShipTo");
|
||||
prop.setType(new FullQualifiedName("Model.Address"));
|
||||
EdmPropertyImpl edmProperty = new EdmPropertyImpl(edm, null, prop);
|
||||
|
||||
String payload = "<data:ShipTo xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" " +
|
||||
" xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
|
||||
" metadata:type=\"#Model.Address\">\n" +
|
||||
" <data:Street>Obere Str. 57</data:Street>\n" +
|
||||
" <data:City>Berlin</data:City>\n" +
|
||||
" <data:Region metadata:null=\"true\"/>\n" +
|
||||
" <data:PostalCode>12209</data:PostalCode>\n" +
|
||||
"</data:ShipTo>";
|
||||
|
||||
Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
|
||||
|
||||
Assert.assertEquals("ShipTo", result.getName());
|
||||
Assert.assertTrue(result.getValue() instanceof ComplexValue);
|
||||
ComplexValue cv = (ComplexValue)result.getValue();
|
||||
Assert.assertEquals("Model.Address", result.getType());
|
||||
Assert.assertEquals("Berlin", getCVProperty(cv, "City").asPrimitive());
|
||||
Assert.assertEquals("Obere Str. 57", getCVProperty(cv, "Street").asPrimitive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void complexCollectionProperty() throws Exception {
|
||||
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
|
||||
final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("CollPropertyComp");
|
||||
String payload = "<metadata:value xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
|
||||
"xmlns:data=\"http://docs.oasis-open.org/odata/ns/data\" "
|
||||
+ "metadata:type=\"#Collection(olingo.odata.test1.CTTwoPrim)\">\n"+
|
||||
" <metadata:element>\n" +
|
||||
" <data:PropertyInt16>123</data:PropertyInt16>\n" +
|
||||
" <data:PropertyString>TEST 1</data:PropertyString>\n" +
|
||||
" </metadata:element>\n" +
|
||||
" <metadata:element>\n" +
|
||||
" <data:PropertyInt16>456</data:PropertyInt16>\n" +
|
||||
" <data:PropertyString>TEST 2</data:PropertyString>\n" +
|
||||
" </metadata:element>\n" +
|
||||
" <metadata:element>\n" +
|
||||
" <data:PropertyInt16>789</data:PropertyInt16>\n" +
|
||||
" <data:PropertyString>TEST 3</data:PropertyString>\n" +
|
||||
" </metadata:element>\n" +
|
||||
"</metadata:value>";
|
||||
Property result = serializer.property(new ByteArrayInputStream(payload.getBytes()), edmProperty).getProperty();
|
||||
|
||||
List<ComplexValue> complex = (List<ComplexValue>)result.getValue();
|
||||
|
||||
Assert.assertEquals(3, complex.size());
|
||||
Assert.assertEquals("Collection(olingo.odata.test1.CTTwoPrim)", result.getType());
|
||||
Assert.assertEquals(edmInt16("123"), getCVProperty(complex.get(0), "PropertyInt16").asPrimitive());
|
||||
Assert.assertEquals("TEST 1", getCVProperty(complex.get(0), "PropertyString").asPrimitive());
|
||||
Assert.assertEquals(edmInt16("789"), getCVProperty(complex.get(2), "PropertyInt16").asPrimitive());
|
||||
Assert.assertEquals("TEST 3", getCVProperty(complex.get(2), "PropertyString").asPrimitive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityReference() throws Exception {
|
||||
String payload = "<metadata:ref xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
|
||||
" metadata:context=\"http://host/service/$metadata#$ref\"\n" +
|
||||
" xmlns=\"http://www.w3.org/2005/Atom\" "+
|
||||
" id=\"http://host/service/Orders(10643)\" />";
|
||||
|
||||
List<URI> result = serializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
|
||||
.getEntityReferences();
|
||||
Assert.assertEquals(1, result.size());
|
||||
Assert.assertEquals("http://host/service/Orders(10643)", result.get(0).toASCIIString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityReferences() throws Exception {
|
||||
String payload = "<feed xmlns=\"http://www.w3.org/2005/Atom\"\n" +
|
||||
" xmlns:metadata=\"http://docs.oasis-open.org/odata/ns/metadata\"\n" +
|
||||
" metadata:context=\"http://host/service/$metadata#Collection($ref)\" >\n" +
|
||||
" <metadata:ref id=\"http://host/service/Orders(10643)\" />\n" +
|
||||
" <metadata:ref id=\"http://host/service/Orders(10759)\" />\n" +
|
||||
"</feed>";
|
||||
|
||||
List<URI> result = serializer.entityReferences(new ByteArrayInputStream(payload.getBytes()))
|
||||
.getEntityReferences();
|
||||
Assert.assertEquals(2, result.size());
|
||||
Assert.assertEquals("http://host/service/Orders(10643)", result.get(0).toASCIIString());
|
||||
Assert.assertEquals("http://host/service/Orders(10759)", result.get(1).toASCIIString());
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -42,7 +42,7 @@ public class UriHelperTest {
|
|||
private static final EdmEntityContainer container = edm.getEntityContainer(
|
||||
new FullQualifiedName("olingo.odata.test1", "Container"));
|
||||
private static final UriHelper helper = new UriHelperImpl();
|
||||
private final DataProvider data = new DataProvider();
|
||||
private final DataProvider data = new DataProvider(edm);
|
||||
|
||||
@Test
|
||||
public void canonicalURL() throws Exception {
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -80,7 +80,7 @@
|
|||
<velocity.version>1.7</velocity.version>
|
||||
<maven.plugin.api.version>3.2.2</maven.plugin.api.version>
|
||||
<maven.plugin.tools.version>3.3</maven.plugin.tools.version>
|
||||
<maven.bundle.plugin.version>2.3.4</maven.bundle.plugin.version>
|
||||
<maven.bundle.plugin.version>2.5.4</maven.bundle.plugin.version>
|
||||
<hc.client.version>4.2.6</hc.client.version>
|
||||
<hc.core.version>4.2.5</hc.core.version>
|
||||
<jackson.version>2.4.2</jackson.version>
|
||||
|
|
Loading…
Reference in New Issue