Java Code Examples for org.apache.olingo.client.api.domain.ClientEntity#setId()
The following examples show how to use
org.apache.olingo.client.api.domain.ClientEntity#setId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AtomTest.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Test public void issue1OLINGO1073() throws Exception { final ClientEntity message = client.getObjectFactory(). newEntity(new FullQualifiedName("Microsoft.OData.SampleService.Models.TripPin.Person")); final ClientComplexValue cityComplexType = getCityComplexType(); final ClientComplexValue locationComplexType = client.getObjectFactory(). newComplexValue("Microsoft.OData.SampleService.Models.TripPin.Location"); locationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln."))); locationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType)); final ClientComplexValue eventLocationComplexType = client.getObjectFactory(). newComplexValue("Microsoft.OData.SampleService.Models.TripPin.EventLocation"); eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("BuildingInfo", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12."))); eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12."))); eventLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType)); final ClientComplexValue airportLocationComplexType = client.getObjectFactory(). newComplexValue("Microsoft.OData.SampleService.Models.TripPin.AirportLocation"); airportLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln123."))); airportLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType)); final ClientCollectionValue<ClientValue> collectionAddressInfo = client.getObjectFactory(). newCollectionValue("Microsoft.OData.SampleService.Models.TripPin.Location"); collectionAddressInfo.add(locationComplexType); collectionAddressInfo.add(eventLocationComplexType); collectionAddressInfo.add(airportLocationComplexType); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("UserName", client.getObjectFactory().newPrimitiveValueBuilder().buildString("russellwhyte"))); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FirstName", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Russell"))); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Whyte"))); final ClientCollectionValue<ClientValue> emailCollectionValue = client.getObjectFactory(). newCollectionValue("String"); emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]")); emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]")); message.getProperties().add(client.getObjectFactory().newCollectionProperty("Emails", emailCollectionValue)); message.getProperties().add(client.getObjectFactory().newCollectionProperty("AddressInfo", collectionAddressInfo)); message.getProperties().add(client.getObjectFactory().newEnumProperty("Gender", client.getObjectFactory().newEnumValue( "Microsoft.OData.SampleService.Models.TripPin.PersonGender", "Male"))); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Concurrency", client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(Long.valueOf("636293755917400747")))); message.setId(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/" + "TripPinServiceRW/People('russellwhyte')")); message.setETag("W/\"08D491CCBE417AAB\""); message.setEditLink(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/" + "TripPinServiceRW/People('russellwhyte')")); String actual = IOUtils.toString(client.getWriter().writeEntity(message, ContentType.APPLICATION_ATOM_XML)); actual = actual.substring(actual.indexOf("<entry")); assertNotNull(actual); String expected = IOUtils.toString(getClass().getResourceAsStream("olingo1073_1.xml")); expected = expected.substring(expected.indexOf("<entry")); expected = expected.trim().replace("\n", "").replace("\r", "").replace("\t", ""); assertEquals(expected, actual); }
Example 2
Source File: AtomTest.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Test public void issue2OLINGO1073() throws Exception { final ClientEntity message = client.getObjectFactory(). newEntity(new FullQualifiedName("Microsoft.OData.SampleService.Models.TripPin.Person")); final ClientComplexValue cityComplexType = getCityComplexType(); final ClientComplexValue locationComplexType = client.getObjectFactory(). newComplexValue("Microsoft.OData.SampleService.Models.TripPin.Location"); locationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln."))); locationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType)); final ClientComplexValue eventLocationComplexType = client.getObjectFactory(). newComplexValue("Microsoft.OData.SampleService.Models.TripPin.EventLocation"); eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("BuildingInfo", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12."))); eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12."))); eventLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType)); final ClientComplexValue airportLocationComplexType = client.getObjectFactory(). newComplexValue("Microsoft.OData.SampleService.Models.TripPin.AirportLocation"); airportLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln123."))); airportLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType)); final ClientCollectionValue<ClientValue> collectionAddressInfo = client.getObjectFactory(). newCollectionValue("Microsoft.OData.SampleService.Models.TripPin.Location"); collectionAddressInfo.add(locationComplexType); collectionAddressInfo.add(eventLocationComplexType); collectionAddressInfo.add(airportLocationComplexType); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("UserName", client.getObjectFactory().newPrimitiveValueBuilder().buildString("russellwhyte"))); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FirstName", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Russell"))); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Whyte"))); final ClientCollectionValue<ClientValue> emailCollectionValue = client.getObjectFactory(). newCollectionValue("String"); emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]")); emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]")); message.getProperties().add(client.getObjectFactory().newCollectionProperty("Emails", emailCollectionValue)); message.getProperties().add(client.getObjectFactory().newCollectionProperty("AddressInfo", collectionAddressInfo)); message.getProperties().add(client.getObjectFactory().newEnumProperty("Gender", client.getObjectFactory().newEnumValue( "Microsoft.OData.SampleService.Models.TripPin.PersonGender", "Male"))); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Concurrency", client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(Long.valueOf("636293755917400747")))); message.setId(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/" + "TripPinServiceRW/People('russellwhyte')")); message.setETag("W/\"08D491CCBE417AAB\""); message.setEditLink(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/" + "TripPinServiceRW/People('russellwhyte')")); InputStream inputStream = client.getWriter().writeEntity(message, ContentType.APPLICATION_ATOM_XML); ResWrap<Entity> entity = new AtomDeserializer().toEntity(inputStream); assertNotNull(entity); assertEquals(7, entity.getPayload().getProperties().size()); assertEquals(3, entity.getPayload().getProperty("AddressInfo").asCollection().size()); assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Location", ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(0)).getTypeName()); assertEquals("#Microsoft.OData.SampleService.Models.TripPin.EventLocation", ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(1)).getTypeName()); assertEquals("#Microsoft.OData.SampleService.Models.TripPin.AirportLocation", ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(2)).getTypeName()); assertEquals("Collection(Microsoft.OData.SampleService.Models.TripPin.Location)", entity.getPayload().getProperty("AddressInfo").getType()); }
Example 3
Source File: JSONTest.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Test public void issue3OLINGO1073() throws Exception { final ClientEntity message = client.getObjectFactory(). newEntity(new FullQualifiedName("Microsoft.OData.SampleService.Models.TripPin.Person")); final ClientComplexValue cityComplexType = getCityComplexType(); final ClientComplexValue locationComplexType = client.getObjectFactory(). newComplexValue("Microsoft.OData.SampleService.Models.TripPin.Location"); locationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln."))); locationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType)); final ClientComplexValue eventLocationComplexType = client.getObjectFactory(). newComplexValue("Microsoft.OData.SampleService.Models.TripPin.EventLocation"); eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("BuildingInfo", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12."))); eventLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln12."))); eventLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType)); final ClientComplexValue airportLocationComplexType = client.getObjectFactory(). newComplexValue("Microsoft.OData.SampleService.Models.TripPin.AirportLocation"); airportLocationComplexType.add(client.getObjectFactory().newPrimitiveProperty("Address", client.getObjectFactory().newPrimitiveValueBuilder().buildString("187 Suffolk Ln123."))); airportLocationComplexType.add(client.getObjectFactory().newComplexProperty("City",cityComplexType)); final ClientCollectionValue<ClientValue> collectionAddressInfo = client.getObjectFactory(). newCollectionValue("Microsoft.OData.SampleService.Models.TripPin.Location"); collectionAddressInfo.add(locationComplexType); collectionAddressInfo.add(eventLocationComplexType); collectionAddressInfo.add(airportLocationComplexType); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("UserName", client.getObjectFactory().newPrimitiveValueBuilder().buildString("russellwhyte"))); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FirstName", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Russell"))); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Whyte"))); final ClientCollectionValue<ClientValue> emailCollectionValue = client.getObjectFactory(). newCollectionValue("String"); emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]")); emailCollectionValue.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]")); message.getProperties().add(client.getObjectFactory().newCollectionProperty("Emails", emailCollectionValue)); message.getProperties().add(client.getObjectFactory().newCollectionProperty("AddressInfo", collectionAddressInfo)); message.getProperties().add(client.getObjectFactory().newEnumProperty("Gender", client.getObjectFactory().newEnumValue( "Microsoft.OData.SampleService.Models.TripPin.PersonGender", "Male"))); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Concurrency", client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(Long.valueOf("636293755917400747")))); message.setId(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/" + "TripPinServiceRW/People('russellwhyte')")); message.setETag("W/\"08D491CCBE417AAB\""); message.setEditLink(URI.create("http://services.odata.org/V4/(S(fe5rsnxo3fkkkk2bvmh1nl1y))/" + "TripPinServiceRW/People('russellwhyte')")); InputStream inputStream = client.getWriter().writeEntity(message, ContentType.JSON_FULL_METADATA); ResWrap<Entity> entity = new JsonDeserializer(true).toEntity(inputStream); assertNotNull(entity); assertEquals(7, entity.getPayload().getProperties().size()); assertEquals(3, entity.getPayload().getProperty("AddressInfo").asCollection().size()); assertEquals("#Microsoft.OData.SampleService.Models.TripPin.Location", ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(0)).getTypeName()); assertEquals("#Microsoft.OData.SampleService.Models.TripPin.EventLocation", ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(1)).getTypeName()); assertEquals("#Microsoft.OData.SampleService.Models.TripPin.AirportLocation", ((ComplexValue)entity.getPayload().getProperty("AddressInfo").asCollection().get(2)).getTypeName()); assertEquals("Collection(Microsoft.OData.SampleService.Models.TripPin.Location)", entity.getPayload().getProperty("AddressInfo").getType()); }