@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());
  }
  @Override
  public ODataResponse updateEntity(
      PutMergePatchUriInfo uriInfo,
      InputStream content,
      String requestContentType,
      boolean merge,
      String contentType)
      throws ODataException {
    LOG.debug("Updating Entity: " + uriInfo);

    EntityProviderReadProperties properties =
        EntityProviderReadProperties.init().mergeSemantic(false).build();

    ODataEntry entry =
        EntityProvider.readEntry(
            requestContentType, uriInfo.getTargetEntitySet(), content, properties);
    // if something goes wrong in deserialization this is managed via the
    // ExceptionMapper,
    // no need for an application to do exception handling here an convert
    // the exceptions in HTTP exceptions

    Map<String, Object> data = entry.getProperties();

    if ("Cars".equals(uriInfo.getTargetEntitySet().getName())) {
      int key = getKeyValue(uriInfo.getKeyPredicates().get(0));

      // if there is no entry with this key available, one should return
      // "404 Not Found"
      // return ODataResponse.status(HttpStatusCodes.NOT_FOUND).build();

      // now one can use the data to create the entry in the backend ...
      String model = (String) data.get("Model");
      // ...
    } else if ("Manufacturers".equals(uriInfo.getTargetEntitySet().getName())) {
      int key = getKeyValue(uriInfo.getKeyPredicates().get(0));
      // now one can use the data to create the entry in the backend ...
    }

    // we can return Status Code 204 No Content because the URI Parsing
    // already guarantees that
    // a) only valid URIs are dispatched (also checked against the metadata)
    // b) 404 Not Found is already returned above, when the entry does not
    // exist
    return ODataResponse.status(HttpStatusCodes.NO_CONTENT).build();
  }
  @Override
  public ODataResponse createEntity(
      PostUriInfo uriInfo, InputStream content, String requestContentType, String contentType)
      throws ODataException {
    LOG.debug("Creating Entity: " + uriInfo);
    // No support for creating and linking a new entry
    if (uriInfo.getNavigationSegments().size() > 0) {
      throw new ODataNotImplementedException();
    }

    // No support for media resources
    if (uriInfo.getStartEntitySet().getEntityType().hasStream()) {
      throw new ODataNotImplementedException();
    }

    EntityProviderReadProperties properties =
        EntityProviderReadProperties.init().mergeSemantic(false).build();

    ODataEntry entry =
        EntityProvider.readEntry(
            requestContentType, uriInfo.getStartEntitySet(), content, properties);
    // if something goes wrong in deserialization this is managed via the
    // ExceptionMapper
    // no need for an application to do exception handling here an convert
    // the exceptions in HTTP exceptions

    Map<String, Object> data = entry.getProperties();
    // now one can use the data to create the entry in the backend ...
    // retrieve the key value after creation, if the key is generated by the
    // server

    // update the data accordingly
    data.put("Id", Integer.valueOf(887788675));

    // serialize the entry, Location header is set by OData Library
    return EntityProvider.writeEntry(
        contentType,
        uriInfo.getStartEntitySet(),
        entry.getProperties(),
        EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot())
            .build());
  }