use of org.apache.olingo.odata2.api.servicedocument.ServiceDocument in project camel by apache.
the class Olingo2ComponentTest method testRead.
@Test
public void testRead() throws Exception {
final Map<String, Object> headers = new HashMap<String, Object>();
// read ServiceDocument
final ServiceDocument document = requestBodyAndHeaders("direct://READSERVICEDOC", null, headers);
assertNotNull(document);
assertFalse("ServiceDocument entity sets", document.getEntitySetsInfo().isEmpty());
LOG.info("Service document has {} entity sets", document.getEntitySetsInfo().size());
// parameter type is java.util.Map
final HashMap<String, String> queryParams = new HashMap<String, String>();
queryParams.put(SystemQueryOption.$top.name(), "5");
headers.put("CamelOlingo2.queryParams", queryParams);
// read ODataFeed
final ODataFeed manufacturers = requestBodyAndHeaders("direct://READFEED", null, headers);
assertNotNull(manufacturers);
final List<ODataEntry> manufacturersEntries = manufacturers.getEntries();
assertFalse("Manufacturers empty entries", manufacturersEntries.isEmpty());
LOG.info("Manufacturers feed has {} entries", manufacturersEntries.size());
// read ODataEntry
headers.clear();
headers.put(Olingo2Constants.PROPERTY_PREFIX + "keyPredicate", "'1'");
final ODataEntry manufacturer = requestBodyAndHeaders("direct://READENTRY", null, headers);
assertNotNull(manufacturer);
final Map<String, Object> properties = manufacturer.getProperties();
assertEquals("Manufacturer Id", "1", properties.get(ID_PROPERTY));
LOG.info("Manufacturer: {}", properties.toString());
}
use of org.apache.olingo.odata2.api.servicedocument.ServiceDocument in project camel by apache.
the class Olingo2AppAPITest method testServiceDocument.
@Test
public void testServiceDocument() throws Exception {
final TestOlingo2ResponseHandler<ServiceDocument> responseHandler = new TestOlingo2ResponseHandler<ServiceDocument>();
olingoApp.read(null, "", null, responseHandler);
final ServiceDocument serviceDocument = responseHandler.await();
final List<Collection> collections = serviceDocument.getAtomInfo().getWorkspaces().get(0).getCollections();
assertEquals("Service Atom Collections", 3, collections.size());
LOG.info("Service Atom Collections: {}", collections);
final List<EdmEntitySetInfo> entitySetsInfo = serviceDocument.getEntitySetsInfo();
assertEquals("Service Entity Sets", 3, entitySetsInfo.size());
LOG.info("Service Document Entries: {}", entitySetsInfo);
}
Aggregations