use of test5.container.Test5Service in project odata-client by davidmoten.
the class CustomRequestTest method testCustomRequestGet.
@Test
public void testCustomRequestGet() {
Test5Service client = //
Test5Service.test().expectRequest(//
"/Products/1").withResponse(//
"/response-product-1.json").withRequestHeaders(RequestHeader.ACCEPT_JSON, //
RequestHeader.ODATA_VERSION).build();
Product p = client._custom().get("https://testing.com/Products/1", Product.class, HttpRequestOptions.EMPTY);
System.out.println(p);
assertEquals(1, (int) p.getID().get());
}
use of test5.container.Test5Service in project odata-client by davidmoten.
the class Test5ServiceTest method testStreamGet.
@Test
public void testStreamGet() throws IOException {
Test5Service client = //
Test5Service.test().expectRequest(//
"/Products/2").withResponse(//
"/response-get-stream.json").withRequestHeaders(RequestHeader.ACCEPT_JSON_METADATA_FULL, //
RequestHeader.ODATA_VERSION).expectRequest(//
"/Photos(123)/%24value").withResponse(//
"/response-get-stream.txt").build();
StreamProvider stream = client.products(2).metadataFull().get().getStream().get();
assertEquals("image/jpeg", stream.contentType());
try (InputStream is = stream.get()) {
byte[] bytes = getBytes(is);
assertEquals("some bytes", new String(bytes));
}
}
Aggregations