Java Code Examples for org.apache.olingo.odata2.api.ep.entry.ODataEntry#getMetadata()
The following examples show how to use
org.apache.olingo.odata2.api.ep.entry.ODataEntry#getMetadata() .
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: XmlFeedConsumerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void roomsFeedWithEtagEntries() throws Exception { InputStream stream = getFileAsStream("feed_rooms_small.xml"); assertNotNull(stream); ODataFeed feed = EntityProvider.readFeed("application/atom+xml", MockFacade.getMockEdm().getDefaultEntityContainer() .getEntitySet( "Rooms"), stream, DEFAULT_PROPERTIES); assertNotNull(feed); FeedMetadata feedMetadata = feed.getFeedMetadata(); assertNotNull(feedMetadata); assertNotNull(feedMetadata.getNextLink()); List<ODataEntry> entries = feed.getEntries(); assertEquals(3, entries.size()); ODataEntry singleRoom = entries.get(0); EntryMetadata roomMetadata = singleRoom.getMetadata(); assertNotNull(roomMetadata); assertEquals("W/\"1\"", roomMetadata.getEtag()); }
Example 2
Source File: XmlEntityConsumerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void readCustomizableFeedMappings() throws Exception { XmlEntityConsumer xec = new XmlEntityConsumer(); EdmEntitySet entitySet = MockFacade.getMockEdm().getEntityContainer("Container2").getEntitySet("Photos"); InputStream reqContent = createContentAsStream(PHOTO_XML); ODataEntry result = xec.readEntry(entitySet, reqContent, EntityProviderReadProperties.init().mergeSemantic(false).build()); // verify EntryMetadata entryMetadata = result.getMetadata(); assertEquals("http://localhost:19000/test/Container2.Photos(Id=1,Type='image%2Fpng')", entryMetadata.getId()); Map<String, Object> data = result.getProperties(); assertEquals("Образ", data.get("Содержание")); assertEquals("Photo1", data.get("Name")); assertEquals("image/png", data.get("Type")); assertNull(data.get("ignore")); }
Example 3
Source File: XmlEntityConsumerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void readCustomizableFeedMappingsWithMergeSemantic() throws Exception { XmlEntityConsumer xec = new XmlEntityConsumer(); EdmEntitySet entitySet = MockFacade.getMockEdm().getEntityContainer("Container2").getEntitySet("Photos"); InputStream reqContent = createContentAsStream(PHOTO_XML); ODataEntry result = xec.readEntry(entitySet, reqContent, EntityProviderReadProperties.init().mergeSemantic(true).build()); // verify EntryMetadata entryMetadata = result.getMetadata(); assertEquals("http://localhost:19000/test/Container2.Photos(Id=1,Type='image%2Fpng')", entryMetadata.getId()); Map<String, Object> data = result.getProperties(); assertEquals("Photo1", data.get("Name")); assertEquals("image/png", data.get("Type")); // ignored customizable feed mapping assertNull(data.get("Содержание")); assertNull(data.get("ignore")); }
Example 4
Source File: XmlEntityConsumerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void readIncompleteEntry() throws Exception { final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms"); InputStream reqContent = createContentAsStream(ROOM_1_XML); final ODataEntry result = new XmlEntityConsumer().readEntry(entitySet, reqContent, EntityProviderReadProperties.init().build()); final EntryMetadata entryMetadata = result.getMetadata(); assertEquals("http://localhost:19000/test/Rooms('1')", entryMetadata.getId()); assertEquals("W/\"1\"", entryMetadata.getEtag()); assertNull(entryMetadata.getUri()); final MediaMetadata mediaMetadata = result.getMediaMetadata(); assertEquals(HttpContentType.APPLICATION_XML, mediaMetadata.getContentType()); assertNull(mediaMetadata.getSourceLink()); assertNull(mediaMetadata.getEditLink()); assertNull(mediaMetadata.getEtag()); final Map<String, Object> properties = result.getProperties(); assertEquals(1, properties.size()); assertEquals("1", properties.get("Id")); assertFalse(properties.containsKey("Seats")); }
Example 5
Source File: JsonEntryConsumerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void readSimpleRoomEntry() throws Exception { ODataEntry roomEntry = prepareAndExecuteEntry(SIMPLE_ENTRY_ROOM, "Rooms", DEFAULT_PROPERTIES); // verify Map<String, Object> properties = roomEntry.getProperties(); assertEquals(4, properties.size()); assertEquals("1", properties.get("Id")); assertEquals("Room 1", properties.get("Name")); assertEquals((short) 1, properties.get("Seats")); assertEquals((short) 1, properties.get("Version")); List<String> associationUris = roomEntry.getMetadata().getAssociationUris("nr_Employees"); assertEquals(1, associationUris.size()); assertEquals("http://localhost:8080/ReferenceScenario.svc/Rooms('1')/nr_Employees", associationUris.get(0)); associationUris = roomEntry.getMetadata().getAssociationUris("nr_Building"); assertEquals(1, associationUris.size()); assertEquals("http://localhost:8080/ReferenceScenario.svc/Rooms('1')/nr_Building", associationUris.get(0)); EntryMetadata metadata = roomEntry.getMetadata(); assertEquals("W/\"1\"", metadata.getEtag()); }
Example 6
Source File: XmlEntityDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void readCustomizableFeedMappings() throws Exception { XmlEntityDeserializer xec = new XmlEntityDeserializer(); EdmEntitySet entitySet = MockFacade.getMockEdm().getEntityContainer("Container2").getEntitySet("Photos"); InputStream reqContent = createContentAsStream(PHOTO_XML); EntityStream stream = new EntityStream(); stream.setContent(reqContent); stream.setReadProperties(DeserializerProperties.init().build()); // execute ODataEntry result = xec.readEntry(entitySet, stream); // verify EntryMetadata entryMetadata = result.getMetadata(); assertEquals("http://localhost:19000/test/Container2.Photos(Id=1,Type='image%2Fpng')", entryMetadata.getId()); Map<String, Object> data = result.getProperties(); assertEquals("Образ", data.get("Содержание")); assertEquals("Photo1", data.get("Name")); assertEquals("image/png", data.get("Type")); assertNull(data.get("ignore")); }
Example 7
Source File: XmlEntityDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void readCustomizableFeedMappingsWithMergeSemantic() throws Exception { XmlEntityDeserializer xec = new XmlEntityDeserializer(); EdmEntitySet entitySet = MockFacade.getMockEdm().getEntityContainer("Container2").getEntitySet("Photos"); InputStream reqContent = createContentAsStream(PHOTO_XML); EntityStream stream = new EntityStream(); stream.setContent(reqContent); stream.setReadProperties(DeserializerProperties.init().build()); // execute ODataEntry result = xec.readEntry(entitySet, stream); // verify EntryMetadata entryMetadata = result.getMetadata(); assertEquals("http://localhost:19000/test/Container2.Photos(Id=1,Type='image%2Fpng')", entryMetadata.getId()); Map<String, Object> data = result.getProperties(); assertEquals("Photo1", data.get("Name")); assertEquals("image/png", data.get("Type")); // ignored customizable feed mapping assertNotNull(data.get("Содержание")); assertNull(data.get("ignore")); }
Example 8
Source File: JsonEntryDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void readSimpleRoomEntry() throws Exception { ODataEntry roomEntry = prepareAndExecuteEntry(SIMPLE_ENTRY_ROOM, "Rooms", DEFAULT_PROPERTIES); // verify Map<String, Object> properties = roomEntry.getProperties(); assertEquals(4, properties.size()); assertEquals("1", properties.get("Id")); assertEquals("Room 1", properties.get("Name")); assertEquals((short) 1, properties.get("Seats")); assertEquals((short) 1, properties.get("Version")); List<String> associationUris = roomEntry.getMetadata().getAssociationUris("nr_Employees"); assertEquals(1, associationUris.size()); assertEquals("http://localhost:8080/ReferenceScenario.svc/Rooms('1')/nr_Employees", associationUris.get(0)); associationUris = roomEntry.getMetadata().getAssociationUris("nr_Building"); assertEquals(1, associationUris.size()); assertEquals("http://localhost:8080/ReferenceScenario.svc/Rooms('1')/nr_Building", associationUris.get(0)); EntryMetadata metadata = roomEntry.getMetadata(); assertEquals("W/\"1\"", metadata.getEtag()); }
Example 9
Source File: XmlEntityConsumerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
/** * Read an inline Room at an Employee * * @throws Exception */ @Test public void readWithInlineContentEmployeeRoomEntry() throws Exception { EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"); InputStream reqContent = createContentAsStream(EMPLOYEE_1_ROOM_XML); // execute XmlEntityConsumer xec = new XmlEntityConsumer(); ODataEntry employee = xec.readEntry(entitySet, reqContent, EntityProviderReadProperties.init().mergeSemantic(true).build()); // validate assertNotNull(employee); Map<String, Object> properties = employee.getProperties(); assertEquals("1", properties.get("EmployeeId")); assertEquals("Walter Winter", properties.get("EmployeeName")); EntryMetadata employeeMetadata = employee.getMetadata(); assertNotNull(employeeMetadata); assertEquals("W/\"1\"", employeeMetadata.getEtag()); // Inline ODataEntry room = (ODataEntry) properties.get("ne_Room"); Map<String, Object> roomProperties = room.getProperties(); assertEquals(4, roomProperties.size()); assertEquals("1", roomProperties.get("Id")); assertEquals("Room 1", roomProperties.get("Name")); assertEquals(Short.valueOf("1"), roomProperties.get("Seats")); assertEquals(Short.valueOf("1"), roomProperties.get("Version")); EntryMetadata roomMetadata = room.getMetadata(); assertNotNull(roomMetadata); assertEquals("W/1", roomMetadata.getEtag()); }
Example 10
Source File: XmlEntityConsumerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void readIncompleteEntryMerge() throws Exception { XmlEntityConsumer xec = new XmlEntityConsumer(); EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms"); InputStream reqContent = createContentAsStream(ROOM_1_XML); ODataEntry result = xec.readEntry(entitySet, reqContent, EntityProviderReadProperties.init().mergeSemantic(true).build()); // verify EntryMetadata entryMetadata = result.getMetadata(); assertEquals("http://localhost:19000/test/Rooms('1')", entryMetadata.getId()); assertEquals("W/\"1\"", entryMetadata.getEtag()); assertEquals(null, entryMetadata.getUri()); MediaMetadata mediaMetadata = result.getMediaMetadata(); assertEquals("application/xml", mediaMetadata.getContentType()); assertEquals(null, mediaMetadata.getSourceLink()); assertEquals(null, mediaMetadata.getEditLink()); assertEquals(null, mediaMetadata.getEtag()); Map<String, Object> properties = result.getProperties(); assertEquals(1, properties.size()); assertEquals("1", properties.get("Id")); assertEquals("Rooms('1')/nr_Building", result.getMetadata().getAssociationUris("nr_Building").get(0)); assertEquals("Rooms('1')/nr_Employees", result.getMetadata().getAssociationUris("nr_Employees").get(0)); }
Example 11
Source File: XmlEntityDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
/** * Read an inline Room at an Employee * * @throws Exception */ @Test public void readWithInlineContentEmployeeRoomEntry() throws Exception { EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"); InputStream reqContent = createContentAsStream(EMPLOYEE_1_ROOM_XML); EntityStream stream = new EntityStream(); stream.setContent(reqContent); stream.setReadProperties(DeserializerProperties.init().build()); // execute XmlEntityDeserializer xec = new XmlEntityDeserializer(); ODataEntry employee = xec.readEntry(entitySet, stream); // validate assertNotNull(employee); Map<String, Object> properties = employee.getProperties(); assertEquals("1", properties.get("EmployeeId")); assertEquals("Walter Winter", properties.get("EmployeeName")); EntryMetadata employeeMetadata = employee.getMetadata(); assertNotNull(employeeMetadata); assertEquals("W/\"1\"", employeeMetadata.getEtag()); // Inline ODataEntry room = (ODataEntry) properties.get("ne_Room"); Map<String, Object> roomProperties = room.getProperties(); assertEquals(4, roomProperties.size()); assertEquals("1", roomProperties.get("Id")); assertEquals("Room 1", roomProperties.get("Name")); assertEquals(Short.valueOf("1"), roomProperties.get("Seats")); assertEquals(Short.valueOf("1"), roomProperties.get("Version")); EntryMetadata roomMetadata = room.getMetadata(); assertNotNull(roomMetadata); assertEquals("W/1", roomMetadata.getEtag()); }
Example 12
Source File: XmlEntityDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void readIncompleteEntry() throws Exception { final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms"); InputStream reqContent = createContentAsStream(ROOM_1_XML); EntityStream stream = new EntityStream(); stream.setContent(reqContent); stream.setReadProperties(DeserializerProperties.init().build()); XmlEntityDeserializer xec = new XmlEntityDeserializer(); // execute ODataEntry result = xec.readEntry(entitySet, stream); final EntryMetadata entryMetadata = result.getMetadata(); assertEquals("http://localhost:19000/test/Rooms('1')", entryMetadata.getId()); assertEquals("W/\"1\"", entryMetadata.getEtag()); assertNull(entryMetadata.getUri()); final MediaMetadata mediaMetadata = result.getMediaMetadata(); assertEquals(HttpContentType.APPLICATION_XML, mediaMetadata.getContentType()); assertNull(mediaMetadata.getSourceLink()); assertNull(mediaMetadata.getEditLink()); assertNull(mediaMetadata.getEtag()); final Map<String, Object> properties = result.getProperties(); assertEquals(1, properties.size()); assertEquals("1", properties.get("Id")); assertFalse(properties.containsKey("Seats")); }
Example 13
Source File: XmlEntityDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void readIncompleteEntryMerge() throws Exception { XmlEntityDeserializer xec = new XmlEntityDeserializer(); EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms"); InputStream reqContent = createContentAsStream(ROOM_1_XML); EntityStream stream = new EntityStream(); stream.setContent(reqContent); stream.setReadProperties(DeserializerProperties.init().build()); // execute ODataEntry result = xec.readEntry(entitySet, stream); // verify EntryMetadata entryMetadata = result.getMetadata(); assertEquals("http://localhost:19000/test/Rooms('1')", entryMetadata.getId()); assertEquals("W/\"1\"", entryMetadata.getEtag()); assertEquals(null, entryMetadata.getUri()); MediaMetadata mediaMetadata = result.getMediaMetadata(); assertEquals("application/xml", mediaMetadata.getContentType()); assertEquals(null, mediaMetadata.getSourceLink()); assertEquals(null, mediaMetadata.getEditLink()); assertEquals(null, mediaMetadata.getEtag()); Map<String, Object> properties = result.getProperties(); assertEquals(1, properties.size()); assertEquals("1", properties.get("Id")); assertEquals("Rooms('1')/nr_Building", result.getMetadata().getAssociationUris("nr_Building").get(0)); assertEquals("Rooms('1')/nr_Employees", result.getMetadata().getAssociationUris("nr_Employees").get(0)); }
Example 14
Source File: XmlEntityConsumerTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Test public void readEntryAtomProperties() throws Exception { // prepare EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"); InputStream contentBody = createContentAsStream(EMPLOYEE_1_XML); // execute XmlEntityConsumer xec = new XmlEntityConsumer(); ODataEntry result = xec.readEntry(entitySet, contentBody, EntityProviderReadProperties.init().mergeSemantic(true).build()); // verify EntryMetadata metadata = result.getMetadata(); assertEquals("http://localhost:19000/Employees('1')", metadata.getId()); assertEquals("W/\"1\"", metadata.getEtag()); List<String> associationUris = metadata.getAssociationUris("ne_Room"); assertEquals(1, associationUris.size()); assertEquals("Employees('1')/ne_Room", associationUris.get(0)); associationUris = metadata.getAssociationUris("ne_Manager"); assertEquals(1, associationUris.size()); assertEquals("Employees('1')/ne_Manager", associationUris.get(0)); associationUris = metadata.getAssociationUris("ne_Team"); assertEquals(1, associationUris.size()); assertEquals("Employees('1')/ne_Team", associationUris.get(0)); assertEquals(null, metadata.getUri()); MediaMetadata mm = result.getMediaMetadata(); assertEquals("Employees('1')/$value", mm.getSourceLink()); assertEquals("mmEtag", mm.getEtag()); assertEquals("application/octet-stream", mm.getContentType()); assertEquals("Employees('1')/$value", mm.getEditLink()); Map<String, Object> data = result.getProperties(); assertEquals(9, data.size()); assertEquals("1", data.get("EmployeeId")); assertEquals("Walter Winter", data.get("EmployeeName")); assertEquals("1", data.get("ManagerId")); assertEquals("1", data.get("RoomId")); assertEquals("1", data.get("TeamId")); }
Example 15
Source File: XmlEntityDeserializerTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Test public void readEntryAtomProperties() throws Exception { // prepare EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees"); InputStream contentBody = createContentAsStream(EMPLOYEE_1_XML); EntityStream stream = new EntityStream(); stream.setContent(contentBody); stream.setReadProperties(DeserializerProperties.init().build()); // execute XmlEntityDeserializer xec = new XmlEntityDeserializer(); ODataEntry result = xec.readEntry(entitySet, stream); // verify EntryMetadata metadata = result.getMetadata(); assertEquals("http://localhost:19000/Employees('1')", metadata.getId()); assertEquals("W/\"1\"", metadata.getEtag()); List<String> associationUris = metadata.getAssociationUris("ne_Room"); assertEquals(1, associationUris.size()); assertEquals("Employees('1')/ne_Room", associationUris.get(0)); associationUris = metadata.getAssociationUris("ne_Manager"); assertEquals(1, associationUris.size()); assertEquals("Employees('1')/ne_Manager", associationUris.get(0)); associationUris = metadata.getAssociationUris("ne_Team"); assertEquals(1, associationUris.size()); assertEquals("Employees('1')/ne_Team", associationUris.get(0)); assertEquals(null, metadata.getUri()); MediaMetadata mm = result.getMediaMetadata(); assertEquals("Employees('1')/$value", mm.getSourceLink()); assertEquals("mmEtag", mm.getEtag()); assertEquals("application/octet-stream", mm.getContentType()); assertEquals("Employees('1')/$value", mm.getEditLink()); Map<String, Object> data = result.getProperties(); assertEquals(9, data.size()); assertEquals("1", data.get("EmployeeId")); assertEquals("Walter Winter", data.get("EmployeeName")); assertEquals("1", data.get("ManagerId")); assertEquals("1", data.get("RoomId")); assertEquals("1", data.get("TeamId")); }