本文整理汇总了Java中org.apache.olingo.commons.api.ex.ODataError类的典型用法代码示例。如果您正苦于以下问题:Java ODataError类的具体用法?Java ODataError怎么用?Java ODataError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataError类属于org.apache.olingo.commons.api.ex包,在下文中一共展示了ODataError类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testCreateTransportRequestWithDesciptionAndOwnerWithNonExistingOwner
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void testCreateTransportRequestWithDesciptionAndOwnerWithNonExistingOwner() throws Exception {
thrown.expect(ODataClientErrorException.class);
thrown.expect(carriesStatusCode(400));
thrown.expect(Matchers.hasServerSideErrorMessage("User DOESNOTEXIST does not exist in the system (or locked)."));
/*
* Comment line below and the captures later on in order to run against
* real back-end.
*/
setMock(examinee, setupMock(new ODataClientErrorException(StatusLines.BAD_REQUEST,
new ODataError().setMessage("User DOESNOTEXIST does not exist in the system (or locked)."))));
examinee.createDevelopmentTransportAdvanced("8000042445", "myDescription", "doesNotExist");
}
开发者ID:SAP,项目名称:devops-cm-client,代码行数:17,代码来源:CMODataClientCreateTransportTest.java
示例2: testCreateTransportRequestForNotExistingChangeDocument
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void testCreateTransportRequestForNotExistingChangeDocument() throws Exception {
/*
* Comment line below and the captures later on in order to run against
* real back-end.
*/
setMock(examinee, setupMock(new ODataClientErrorException(StatusLines.BAD_REQUEST,
new ODataError().setMessage("DOES_NOT_E not found."))));
thrown.expect(ODataClientErrorException.class);
thrown.expect(carriesStatusCode(400)); // TODO 404 would be better ...
thrown.expect(hasServerSideErrorMessage("DOES_NOT_E not found."));
try {
examinee.createDevelopmentTransport("DOES_NOT_EXIST");
} catch(Exception e) {
assertThat(
address.getValue().toASCIIString(),
is(equalTo(SERVICE_ENDPOINT + "createTransport?ChangeID='DOES_NOT_EXIST'")));
assertThat(contentType.getValue(), is(equalTo("application/atom+xml")));
throw e;
}
}
开发者ID:SAP,项目名称:devops-cm-client,代码行数:25,代码来源:CMODataClientCreateTransportTest.java
示例3: testUploadFileToNonExistingTransportFails
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void testUploadFileToNonExistingTransportFails() throws Exception {
thrown.expect(HttpClientException.class);
thrown.expect(hasRootCause(ODataClientErrorException.class));
thrown.expect(carriesStatusCode(400));
thrown.expect(hasServerSideErrorMessage("Resource not found for segment 'Transport'."));
// comment statement below for testing against real backend.
setMock(examinee, setupUploadFileFailsMock(new HttpClientException(
new RuntimeException(new ODataClientErrorException(
StatusLines.BAD_REQUEST,
new ODataError().setMessage("Resource not found for segment 'Transport'."))))));
//transport 'L21K900XFG' does not exist
examinee.uploadFileToTransport("8000042445", "L21K900XFG", testFile.getAbsolutePath(), "HCP");
}
开发者ID:SAP,项目名称:devops-cm-client,代码行数:18,代码来源:CMODataClientFileUploadTest.java
示例4: testGetTransportsChangeIdDoesNotExist
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void testGetTransportsChangeIdDoesNotExist() throws Exception {
thrown.expect(ODataClientErrorException.class);
thrown.expect(carriesStatusCode(400)); // TODO 404 would be better
thrown.expect(hasServerSideErrorMessage("Resource not found for segment ''"));
// comment statement below for testing against real backend.
// Assert for the captures below needs to be commented also in this case.
setMock(examinee, setupMock(
new ODataClientErrorException(
StatusLines.BAD_REQUEST,
new ODataError().setMessage("Resource not found for segment ''"))));
try {
examinee.getChangeTransports("DOES_NOT_EXIST");
} catch(Exception e) {
assertThat(address.getValue().toASCIIString(),
is(equalTo(SERVICE_ENDPOINT + "Changes('DOES_NOT_EXIST')/Transports")));
throw e;
}
}
开发者ID:SAP,项目名称:devops-cm-client,代码行数:23,代码来源:CMODataClientGetTransportsTest.java
示例5: readException
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void readException() throws Exception {
ODataEntityRequest<ClientEntity> request = getClient().getRetrieveRequestFactory()
.getEntityRequest(getClient().newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_MIX_PRIM_COLL_COMP).appendKeySegment("42").build());
assertNotNull(request);
setCookieHeader(request);
try {
request.execute();
fail("Expected Exception not thrown!");
} catch (final ODataClientErrorException e) {
assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
final ODataError error = e.getODataError();
assertThat(error.getMessage(), containsString("key"));
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:BasicITCase.java
示例6: writeErrorDocument
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
public void writeErrorDocument(final JsonGenerator json, final ODataError error)
throws IOException, SerializerException {
if (error == null) {
throw new SerializerException("ODataError object MUST NOT be null!",
SerializerException.MessageKeys.NULL_INPUT);
}
json.writeStartObject();
json.writeFieldName(Constants.JSON_ERROR);
json.writeStartObject();
writeODataError(json, error.getCode(), error.getMessage(), error.getTarget());
if (error.getDetails() != null) {
json.writeArrayFieldStart(Constants.ERROR_DETAILS);
for (ODataErrorDetail detail : error.getDetails()) {
json.writeStartObject();
writeODataError(json, detail.getCode(), detail.getMessage(), detail.getTarget());
json.writeEndObject();
}
json.writeEndArray();
}
json.writeEndObject();
json.writeEndObject();
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:ODataErrorSerializer.java
示例7: test1OLINGO1102
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void test1OLINGO1102() throws Exception {
ODataClient odataClient = ODataClientFactory.getClient();
InputStream entity = getClass().getResourceAsStream("500error." + getSuffix(ContentType.JSON));
StatusLine statusLine = mock(StatusLine.class);
when(statusLine.getStatusCode()).thenReturn(500);
when(statusLine.toString()).thenReturn("Internal Server Error");
ODataClientErrorException exp = (ODataClientErrorException) ODataErrorResponseChecker.
checkResponse(odataClient, statusLine, entity, "Json");
assertTrue(exp.getMessage().contains("(500) Internal Server Error"));
ODataError error = exp.getODataError();
assertTrue(error.getMessage().startsWith("Internal Server Error"));
assertEquals(500, Integer.parseInt(error.getCode()));
assertEquals(2, error.getInnerError().size());
assertEquals("\"Method does not support entities of specific type\"", error.getInnerError().get("message"));
assertEquals("\"FaultException\"", error.getInnerError().get("type"));
assertNull(error.getDetails());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ErrorTest.java
示例8: testReleaseTransportFailsDueTransportHasAlreadyBeenReleased
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void testReleaseTransportFailsDueTransportHasAlreadyBeenReleased() throws Exception {
thrown.expect(ODataClientErrorException.class);
thrown.expect(carriesStatusCode(400)); // TODO: 404 would be better
thrown.expect(hasServerSideErrorMessage("Transport request L21K900026 can no longer be changed."));
setMock(examinee, setupMock(new ODataClientErrorException(
StatusLines.BAD_REQUEST,
new ODataError().setMessage("Transport request L21K900026 can no longer be changed."))));
examinee.releaseDevelopmentTransport("8000038673", "L21K900026");
}
开发者ID:SAP,项目名称:devops-cm-client,代码行数:13,代码来源:CMODataClientReleaseTransportTest.java
示例9: testReleaseTransportFailsDueToNotExistingChange
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void testReleaseTransportFailsDueToNotExistingChange() throws Exception {
thrown.expect(ODataClientErrorException.class);
thrown.expect(carriesStatusCode(400)); // TODO: 404 would be better
thrown.expect(hasServerSideErrorMessage("CHANGE_ID_ not found."));
// comment statement below for testing against real backend.
setMock(examinee, setupMock(new ODataClientErrorException(
StatusLines.BAD_REQUEST,
new ODataError().setMessage("CHANGE_ID_ not found."))));
examinee.releaseDevelopmentTransport("CHANGE_ID_DOES_NOT_EXIST", "TRANSPORT_REQUEST_DOES_ALSO_NOT_EXIST");
}
开发者ID:SAP,项目名称:devops-cm-client,代码行数:14,代码来源:CMODataClientReleaseTransportTest.java
示例10: testReleaseTransportFailsDueToNotExistingTransport
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void testReleaseTransportFailsDueToNotExistingTransport() throws Exception {
thrown.expect(ODataClientErrorException.class);
thrown.expect(carriesStatusCode(400)); // TODO: 404 would be better
thrown.expect(hasServerSideErrorMessage("DOES_NOT_EXIST not found."));
// comment statement below for testing against real backend.
setMock(examinee, setupMock(new ODataClientErrorException(
StatusLines.BAD_REQUEST,
new ODataError().setMessage("DOES_NOT_EXIST not found."))));
examinee.releaseDevelopmentTransport("8000038673", "DOES_NOT_EXIST");
}
开发者ID:SAP,项目名称:devops-cm-client,代码行数:15,代码来源:CMODataClientReleaseTransportTest.java
示例11: testUploadFileToClosedTransportFails
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void testUploadFileToClosedTransportFails() throws Exception {
thrown.expect(HttpClientException.class);
thrown.expect(hasRootCause(ODataClientErrorException.class));
thrown.expect(carriesStatusCode(400));
thrown.expect(hasServerSideErrorMessage(
"Internal Error - assertion skipped (see long text). "
+ "Diagnosis An invalid system status was reached "
+ "in the Change and Transport Organizer. "
+ "System Response The internal check using an assertion "
+ "was ignored due to the setti."));
// comment statement below for testing against real backend.
setMock(examinee, setupUploadFileFailsMock(new HttpClientException(
new RuntimeException(new ODataClientErrorException(
StatusLines.BAD_REQUEST,
new ODataError().setMessage(
"Internal Error - assertion skipped (see long text). "
+ "Diagnosis An invalid system status was reached "
+ "in the Change and Transport Organizer. "
+ "System Response The internal check using an assertion "
+ "was ignored due to the setti."))))));
//transport 'L21K900026' exists, but is closed.
examinee.uploadFileToTransport("8000038673", "L21K900026", testFile.getAbsolutePath(), "HCP");
}
开发者ID:SAP,项目名称:devops-cm-client,代码行数:28,代码来源:CMODataClientFileUploadTest.java
示例12: ErrorDocument
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
/**
* Constructor.
*
* @param error
* error information
*/
public ErrorDocument(ODataError error) {
this.error = new ODataError()
.setCode(error.getCode())
.setMessage(error.getMessage())
.setTarget(error.getTarget())
.setDetails(error.getDetails())
.setInnerError(error.getInnerError());
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:15,代码来源:ErrorDocument.java
示例13: ODataClientErrorException
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
/**
* Constructor.
*
* @param statusLine request status info.
* @param error OData error to be wrapped.
*/
public ODataClientErrorException(final StatusLine statusLine, final ODataError error) {
super(error == null ?
statusLine.toString() :
(error.getCode() == null || error.getCode().isEmpty() ? "" : "(" + error.getCode() + ") ")
+ error.getMessage() + " [" + statusLine.toString() + "]");
this.statusLine = statusLine;
this.error = error;
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:16,代码来源:ODataClientErrorException.java
示例14: toError
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Override
public ODataError toError(final InputStream input) throws ODataDeserializerException {
try {
final XMLEventReader reader = getReader(input);
final StartElement start = skipBeforeFirstStartElement(reader);
return error(reader, start);
} catch (XMLStreamException e) {
throw new ODataDeserializerException(e);
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:11,代码来源:AtomDeserializer.java
示例15: toError
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Override
public ODataError toError(final InputStream input) throws ODataDeserializerException {
try {
parser = new JsonFactory(new ObjectMapper()).createParser(input);
return new JsonODataErrorDeserializer(serverMode).doDeserialize(parser);
} catch (final IOException e) {
throw new ODataDeserializerException(e);
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:10,代码来源:JsonDeserializer.java
示例16: simple
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
private ODataError simple(final ContentType contentType) throws ODataDeserializerException {
final ODataError error = error("error", contentType);
assertEquals("501", error.getCode());
assertEquals("Unsupported functionality", error.getMessage());
assertEquals("query", error.getTarget());
// verify details
final ODataErrorDetail detail = error.getDetails().get(0);
assertEquals("Code should be correct", "301", detail.getCode());
assertEquals("Target should be correct", "$search", detail.getTarget());
assertEquals("Message should be correct", "$search query option not supported", detail.getMessage());
return error;
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:14,代码来源:ErrorTest.java
示例17: jsonSimple
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Test
public void jsonSimple() throws Exception {
final ODataError error = simple(ContentType.JSON);
// verify inner error dictionary
final Map<String, String> innerErr = error.getInnerError();
assertEquals("innerError dictionary size should be correct", 2, innerErr.size());
assertEquals("innerError['context'] should be correct",
"{\"key1\":\"for debug deployment only\"}", innerErr.get("context"));
assertEquals("innerError['trace'] should be correct",
"[\"callmethod1 etc\",\"callmethod2 etc\"]", innerErr.get("trace"));
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:13,代码来源:ErrorTest.java
示例18: matches
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
@Override
public boolean matches(Object o) {
Throwable rootCause = getRootCause((Exception)o);
if(! (rootCause instanceof ODataClientErrorException))
return false;
ODataError error = ((ODataClientErrorException)rootCause).getODataError();
if(error == null)
return false;
actualErrorMessage = error.getMessage();
return actualErrorMessage != null && actualErrorMessage.contains(expected);
}
开发者ID:SAP,项目名称:devops-cm-client,代码行数:17,代码来源:Matchers.java
示例19: setupChangeDoesNotExistMock
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
private ODataClient setupChangeDoesNotExistMock() {
return setupMock(
new ODataClientErrorException(
StatusLines.NOT_FOUND,
new ODataError().setMessage("Resource not found for segment ''.")));
}
开发者ID:SAP,项目名称:devops-cm-client,代码行数:7,代码来源:CMODataClientChangesTest.java
示例20: doDeserialize
import org.apache.olingo.commons.api.ex.ODataError; //导入依赖的package包/类
protected ODataError doDeserialize(final JsonParser parser) throws IOException {
final ODataError error = new ODataError();
final ObjectNode tree = parser.getCodec().readTree(parser);
if (tree.has(Constants.JSON_ERROR)) {
final JsonNode errorNode = tree.get(Constants.JSON_ERROR);
if (errorNode.has(Constants.ERROR_CODE)) {
error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
}
if (errorNode.has(Constants.ERROR_MESSAGE)) {
final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
if (message.isValueNode()) {
error.setMessage(message.textValue());
} else if (message.isObject()) {
error.setMessage(message.get(Constants.VALUE).asText());
}
}
if (errorNode.has(Constants.ERROR_TARGET)) {
error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
}
if (errorNode.hasNonNull(Constants.ERROR_DETAILS)) {
List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
JsonODataErrorDetailDeserializer detailDeserializer = new JsonODataErrorDetailDeserializer(serverMode);
for (JsonNode jsonNode : errorNode.get(Constants.ERROR_DETAILS)) {
details.add(detailDeserializer.doDeserialize(jsonNode.traverse(parser.getCodec()))
.getPayload());
}
error.setDetails(details);
}
if (errorNode.hasNonNull(Constants.ERROR_INNERERROR)) {
HashMap<String, String> innerErrorMap = new HashMap<String, String>();
final JsonNode innerError = errorNode.get(Constants.ERROR_INNERERROR);
for (final Iterator<String> itor = innerError.fieldNames(); itor.hasNext();) {
final String keyTmp = itor.next();
final String val = innerError.get(keyTmp).toString();
innerErrorMap.put(keyTmp, val);
}
error.setInnerError(innerErrorMap);
}
}
return error;
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:47,代码来源:JsonODataErrorDeserializer.java
注:本文中的org.apache.olingo.commons.api.ex.ODataError类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论