本文整理汇总了Java中org.apache.olingo.odata2.api.ep.EntityProvider.readFunctionImport方法的典型用法代码示例。如果您正苦于以下问题:Java EntityProvider.readFunctionImport方法的具体用法?Java EntityProvider.readFunctionImport怎么用?Java EntityProvider.readFunctionImport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.odata2.api.ep.EntityProvider
的用法示例。
在下文中一共展示了EntityProvider.readFunctionImport方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: complexTypeCollection
import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@Test
public void complexTypeCollection() throws Exception {
final HttpResponse response = callUri("AllLocations?$format=json");
checkMediaType(response, HttpContentType.APPLICATION_JSON);
final String body = getBody(response);
assertEquals("{\"d\":{\"__metadata\":{\"type\":\"Collection(RefScenario.c_Location)\"},"
+ "\"results\":[{\"__metadata\":{\"type\":\"RefScenario.c_Location\"},"
+ "\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},"
+ "\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"},\"Country\":\"Germany\"},"
+ "{\"__metadata\":{\"type\":\"RefScenario.c_Location\"},"
+ "\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},"
+ "\"PostalCode\":\"69190\",\"CityName\":\"Walldorf\"},\"Country\":\"Germany\"}]}}",
body);
final Object result = EntityProvider.readFunctionImport(HttpContentType.APPLICATION_JSON,
getEntityContainer().getFunctionImport("AllLocations"), StringHelper.encapsulate(body),
EntityProviderReadProperties.init().build());
assertNotNull(result);
final List<?> collection = (List<?>) result;
@SuppressWarnings("unchecked")
final Map<String, Object> secondLocation = (Map<String, Object>) collection.get(1);
@SuppressWarnings("unchecked")
final Map<String, Object> secondCity = (Map<String, Object>) secondLocation.get("City");
assertEquals(CITY_2_NAME, secondCity.get("CityName"));
}
示例2: complexType
import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void complexType() throws Exception {
final HttpResponse response = callUri("MostCommonLocation?$format=json");
checkMediaType(response, HttpContentType.APPLICATION_JSON);
final String body = getBody(response);
assertEquals("{\"d\":{\"MostCommonLocation\":"
+ "{\"__metadata\":{\"type\":\"RefScenario.c_Location\"},"
+ "\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},"
+ "\"PostalCode\":\"69190\",\"CityName\":\"" + CITY_2_NAME + "\"},"
+ "\"Country\":\"Germany\"}}}",
body);
final Object result = EntityProvider.readFunctionImport(HttpContentType.APPLICATION_JSON,
getEntityContainer().getFunctionImport("MostCommonLocation"), StringHelper.encapsulate(body),
EntityProviderReadProperties.init().build());
assertNotNull(result);
Map<String, Object> resultMap = (Map<String, Object>) result;
assertNotNull(resultMap);
assertFalse(resultMap.isEmpty());
resultMap = (Map<String, Object>) resultMap.get("City");
assertNotNull(resultMap);
assertFalse(resultMap.isEmpty());
assertEquals(CITY_2_NAME, resultMap.get("CityName"));
}
示例3: simpleTypeCollection
import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@Test
public void simpleTypeCollection() throws Exception {
final HttpResponse response = callUri("AllUsedRoomIds?$format=json");
checkMediaType(response, HttpContentType.APPLICATION_JSON);
final String body = getBody(response);
assertEquals("{\"d\":{\"__metadata\":{\"type\":\"Collection(Edm.String)\"},"
+ "\"results\":[\"1\",\"2\",\"3\"]}}",
body);
final Object result = EntityProvider.readFunctionImport(HttpContentType.APPLICATION_JSON,
getEntityContainer().getFunctionImport("AllUsedRoomIds"), StringHelper.encapsulate(body),
EntityProviderReadProperties.init().build());
assertNotNull(result);
assertEquals(Arrays.asList("1", "2", "3"), result);
}
示例4: simpleType
import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@Test
public void simpleType() throws Exception {
final HttpResponse response = callUri("MaximalAge?$format=json");
checkMediaType(response, HttpContentType.APPLICATION_JSON);
final String body = getBody(response);
assertEquals("{\"d\":{\"MaximalAge\":56}}", body);
final Object result = EntityProvider.readFunctionImport(HttpContentType.APPLICATION_JSON,
getEntityContainer().getFunctionImport("MaximalAge"), StringHelper.encapsulate(body),
EntityProviderReadProperties.init().build());
assertNotNull(result);
assertEquals(Short.valueOf(EMPLOYEE_3_AGE), result);
}
示例5: entity
import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@Test
public void entity() throws Exception {
final String expected = getBody(callUri("Employees('3')?$format=json"));
final HttpResponse response = callUri("OldestEmployee", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON);
checkMediaType(response, HttpContentType.APPLICATION_JSON);
final String body = getBody(response);
assertEquals(expected, body);
final Object result = EntityProvider.readFunctionImport(HttpContentType.APPLICATION_JSON,
getEntityContainer().getFunctionImport("OldestEmployee"), StringHelper.encapsulate(body),
EntityProviderReadProperties.init().build());
assertNotNull(result);
final ODataEntry entry = (ODataEntry) result;
assertEquals("3", entry.getProperties().get("EmployeeId"));
}
示例6: functionImports
import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@Test
public void functionImports() throws Exception {
HttpResponse response = callUri("EmployeeSearch('1')/ne_Room/Id/$value?q='alter'");
checkMediaType(response, HttpContentType.TEXT_PLAIN_UTF8);
checkEtag(response, "W/\"1\"");
assertEquals("1", getBody(response));
assertFalse(getBody(callUri("EmployeeSearch?q='-'")).contains("entry"));
response = callUri("AllLocations", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_XML);
checkMediaType(response, HttpContentType.APPLICATION_XML_UTF8);
String body = getBody(response);
assertXpathExists("/d:AllLocations/d:element/d:City[d:CityName=\"" + CITY_2_NAME + "\"]", body);
final HttpResponse metadataResponse = callUri("$metadata");
final EdmEntityContainer entityContainer = EntityProvider.readMetadata(metadataResponse.getEntity().getContent(),
false).getDefaultEntityContainer();
getBody(metadataResponse);
Object result = EntityProvider.readFunctionImport(HttpContentType.APPLICATION_XML,
entityContainer.getFunctionImport("AllLocations"), StringHelper.encapsulate(body),
EntityProviderReadProperties.init().build());
assertNotNull(result);
final List<?> collection = (List<?>) result;
@SuppressWarnings("unchecked")
final Map<String, Object> secondLocation = (Map<String, Object>) collection.get(1);
@SuppressWarnings("unchecked")
final Map<String, Object> secondCity = (Map<String, Object>) secondLocation.get("City");
assertEquals(CITY_2_NAME, secondCity.get("CityName"));
response = callUri("AllUsedRoomIds", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_XML);
checkMediaType(response, HttpContentType.APPLICATION_XML_UTF8);
body = getBody(response);
assertXpathExists("/d:AllUsedRoomIds[d:element=\"3\"]", body);
result = EntityProvider.readFunctionImport(HttpContentType.APPLICATION_XML,
entityContainer.getFunctionImport("AllUsedRoomIds"), StringHelper.encapsulate(body),
EntityProviderReadProperties.init().build());
assertNotNull(result);
assertEquals(Arrays.asList("1", "2", "3"), result);
response = callUri("MaximalAge", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_XML);
checkMediaType(response, HttpContentType.APPLICATION_XML_UTF8);
assertXpathEvaluatesTo(EMPLOYEE_3_AGE, "/d:MaximalAge", getBody(response));
response = callUri("MostCommonLocation", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_XML);
checkMediaType(response, HttpContentType.APPLICATION_XML_UTF8);
assertXpathEvaluatesTo(CITY_2_NAME, "/d:MostCommonLocation/d:City/d:CityName", getBody(response));
checkUri("ManagerPhoto?Id='1'");
response = callUri("ManagerPhoto/$value?Id='1'");
checkMediaType(response, IMAGE_JPEG);
assertNull(response.getFirstHeader(HttpHeaders.ETAG));
assertNotNull(getBody(response));
response = callUri("OldestEmployee", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_XML);
checkMediaType(response, HttpContentType.APPLICATION_XML_UTF8);
assertXpathEvaluatesTo(EMPLOYEE_3_NAME, "/atom:entry/m:properties/d:EmployeeName", getBody(response));
response = callUri("OldestEmployee?$format=xml");
checkMediaType(response, HttpContentType.APPLICATION_XML_UTF8);
assertXpathEvaluatesTo(EMPLOYEE_3_NAME, "/atom:entry/m:properties/d:EmployeeName", getBody(response));
badRequest("AllLocations/$count");
badRequest("AllUsedRoomIds/$value");
badRequest("MaximalAge()");
badRequest("MostCommonLocation/City/CityName");
badRequest("ManagerPhoto");
badRequest("OldestEmployee()");
notFound("ManagerPhoto?Id='2'");
}