Search in sources :

Example 1 with ServiceDocument

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());
}
Also used : ODataFeed(org.apache.olingo.odata2.api.ep.feed.ODataFeed) HashMap(java.util.HashMap) ServiceDocument(org.apache.olingo.odata2.api.servicedocument.ServiceDocument) ODataEntry(org.apache.olingo.odata2.api.ep.entry.ODataEntry) Test(org.junit.Test)

Example 2 with ServiceDocument

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);
}
Also used : Collection(org.apache.olingo.odata2.api.servicedocument.Collection) ServiceDocument(org.apache.olingo.odata2.api.servicedocument.ServiceDocument) EdmEntitySetInfo(org.apache.olingo.odata2.api.edm.EdmEntitySetInfo) Test(org.junit.Test)

Aggregations

ServiceDocument (org.apache.olingo.odata2.api.servicedocument.ServiceDocument)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 EdmEntitySetInfo (org.apache.olingo.odata2.api.edm.EdmEntitySetInfo)1 ODataEntry (org.apache.olingo.odata2.api.ep.entry.ODataEntry)1 ODataFeed (org.apache.olingo.odata2.api.ep.feed.ODataFeed)1 Collection (org.apache.olingo.odata2.api.servicedocument.Collection)1