@Test public void testSingletonSampleEntity() throws ODataClientException { SingletonSample singletonSample = new SingletonSample(); singletonSample.setId(UUID.randomUUID()); BasicODataClientQuery query = new BasicODataClientQuery.Builder() .withEntityType(SingletonSample.class) .build(); String marshalledEntity = oDataEntityMarshaller.marshallEntity(singletonSample, query); Object unmarshalledEntity = oDataEntityUnmarshaller.unmarshallEntity(marshalledEntity, query); assertNotNull(unmarshalledEntity); assertEquals(singletonSample, unmarshalledEntity); }
@Override public String marshallEntity(Object oDataEntity, ODataClientQuery query) throws ODataClientException { String result; ODataResponse.Builder builder = new ODataResponse.Builder() .setStatus(OK); try { String encodedServiceQueryUrl = url + "/" + URLEncoder.encode(query.getEdmEntityName(), StandardCharsets.UTF_8.name()); ODataUri oDataServiceUri = new ODataParserImpl().parseUri(encodedServiceQueryUrl, entityDataModel); atomRenderer.render(buildODataPostContext(oDataServiceUri), QueryResult.from(oDataEntity), builder); result = builder.build().getBodyText(StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException | ODataException e) { throw new ODataClientException("Unable to marshall OData entity", e); } return result; }
AtomEntityMarshaller implements ODataEntityMarshaller { @Override public String marshallEntity(Object oDataEntity, ODataClientQuery query) throws ODataClientException { String result; ODataResponse.Builder builder = new ODataResponse.Builder() .setStatus(OK); try { String encodedServiceQueryUrl = url + "/" + URLEncoder.encode(query.getEdmEntityName(), StandardCharsets.UTF_8.name()); ODataUri oDataServiceUri = new ODataParserImpl().parseUri(encodedServiceQueryUrl, entityDataModel); atomRenderer.render(buildODataPostContext(oDataServiceUri), QueryResult.from(oDataEntity), builder); result = builder.build().getBodyText(StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException | ODataException e) { throw new ODataClientException("Unable to marshall OData entity", e); } return result; } }
AtomEntityMarshaller implements ODataEntityMarshaller { @Override public String marshallEntity(Object oDataEntity, ODataClientQuery query) throws ODataClientException { String result; ODataResponse.Builder builder = new ODataResponse.Builder() .setStatus(OK); try { String encodedServiceQueryUrl = url + "/" + URLEncoder.encode(query.getEdmEntityName(), StandardCharsets.UTF_8.name()); ODataUri oDataServiceUri = new ODataParserImpl().parseUri(encodedServiceQueryUrl, entityDataModel); atomRenderer.render(buildODataPostContext(oDataServiceUri), QueryResult.from(oDataEntity), builder); result = builder.build().getBodyText(StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException | ODataException e) { throw new ODataClientException("Unable to marshall OData entity", e); } return result; } AtomEntityMarshaller(Iterable<Class<?>> edmEntityClasses, String url); protected  AtomEntityMarshaller(Iterable<Class<?>> edmEntityClasses, String url, AbstractAtomRenderer atomRenderer); }
AtomEntityMarshaller implements ODataEntityMarshaller { @Override public String marshallEntity(Object oDataEntity, ODataClientQuery query) throws ODataClientException { String result; ODataResponse.Builder builder = new ODataResponse.Builder() .setStatus(OK); try { String encodedServiceQueryUrl = url + "/" + URLEncoder.encode(query.getEdmEntityName(), StandardCharsets.UTF_8.name()); ODataUri oDataServiceUri = new ODataParserImpl().parseUri(encodedServiceQueryUrl, entityDataModel); atomRenderer.render(buildODataPostContext(oDataServiceUri), QueryResult.from(oDataEntity), builder); result = builder.build().getBodyText(StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException | ODataException e) { throw new ODataClientException("Unable to marshall OData entity", e); } return result; } AtomEntityMarshaller(Iterable<Class<?>> edmEntityClasses, String url); protected  AtomEntityMarshaller(Iterable<Class<?>> edmEntityClasses, String url, AbstractAtomRenderer atomRenderer); @Override String marshallEntity(Object oDataEntity, ODataClientQuery query); @Override String marshallEntities(List<?> oDataEntities, ODataClientQuery query); }
AtomEntityMarshaller implements ODataEntityMarshaller { @Override public String marshallEntity(Object oDataEntity, ODataClientQuery query) throws ODataClientException { String result; ODataResponse.Builder builder = new ODataResponse.Builder() .setStatus(OK); try { String encodedServiceQueryUrl = url + "/" + URLEncoder.encode(query.getEdmEntityName(), StandardCharsets.UTF_8.name()); ODataUri oDataServiceUri = new ODataParserImpl().parseUri(encodedServiceQueryUrl, entityDataModel); atomRenderer.render(buildODataPostContext(oDataServiceUri), QueryResult.from(oDataEntity), builder); result = builder.build().getBodyText(StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException | ODataException e) { throw new ODataClientException("Unable to marshall OData entity", e); } return result; } AtomEntityMarshaller(Iterable<Class<?>> edmEntityClasses, String url); protected  AtomEntityMarshaller(Iterable<Class<?>> edmEntityClasses, String url, AbstractAtomRenderer atomRenderer); @Override String marshallEntity(Object oDataEntity, ODataClientQuery query); @Override String marshallEntities(List<?> oDataEntities, ODataClientQuery query);  }