本文整理汇总了Java中org.mockserver.mock.Expectation.getHttpResponse方法的典型用法代码示例。如果您正苦于以下问题:Java Expectation.getHttpResponse方法的具体用法?Java Expectation.getHttpResponse怎么用?Java Expectation.getHttpResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mockserver.mock.Expectation
的用法示例。
在下文中一共展示了Expectation.getHttpResponse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ApiExpectation
import org.mockserver.mock.Expectation; //导入方法依赖的package包/类
public ApiExpectation(ApiSpecification specification, Expectation expectation) {
this.specification = specification;
this.request = expectation.getHttpRequest();
this.response = expectation.getHttpResponse(false);
}
示例2: serialize
import org.mockserver.mock.Expectation; //导入方法依赖的package包/类
@Override
public String serialize(int numberOfSpacesToIndent, Expectation expectation) {
StringBuffer output = new StringBuffer();
if (expectation != null) {
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append("new MockServerClient(\"localhost\", 1080)");
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(".when(");
output.append(new HttpRequestToJavaSerializer().serialize(numberOfSpacesToIndent + 1, expectation.getHttpRequest()));
if (expectation.getTimeToLive() != null) {
output.append(",").append(new TimesToJavaSerializer().serialize(numberOfSpacesToIndent + 1, expectation.getTimes()));
}
if (expectation.getTimeToLive() != null) {
output.append(",").append(new TimeToLiveToJavaSerializer().serialize(numberOfSpacesToIndent + 1, expectation.getTimeToLive()));
}
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(")");
if (expectation.getHttpResponse() != null) {
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(".respond(");
output.append(new HttpResponseToJavaSerializer().serialize(numberOfSpacesToIndent + 1, expectation.getHttpResponse()));
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(")");
}
if (expectation.getHttpResponseTemplate() != null) {
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(".respond(");
output.append(new HttpTemplateToJavaSerializer().serialize(numberOfSpacesToIndent + 1, expectation.getHttpResponseTemplate()));
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(")");
}
if (expectation.getHttpResponseClassCallback() != null) {
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(".respond(");
output.append(new HttpClassCallbackToJavaSerializer().serialize(numberOfSpacesToIndent + 1, expectation.getHttpResponseClassCallback()));
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(")");
}
if (expectation.getHttpResponseObjectCallback() != null) {
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append("/*NOT POSSIBLE TO GENERATE CODE FOR OBJECT CALLBACK*/");
}
if (expectation.getHttpForward() != null) {
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(".forward(");
output.append(new HttpForwardToJavaSerializer().serialize(numberOfSpacesToIndent + 1, expectation.getHttpForward()));
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(")");
}
if (expectation.getHttpForwardTemplate() != null) {
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(".forward(");
output.append(new HttpTemplateToJavaSerializer().serialize(numberOfSpacesToIndent + 1, expectation.getHttpForwardTemplate()));
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(")");
}
if (expectation.getHttpForwardClassCallback() != null) {
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(".forward(");
output.append(new HttpClassCallbackToJavaSerializer().serialize(numberOfSpacesToIndent + 1, expectation.getHttpForwardClassCallback()));
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(")");
}
if (expectation.getHttpForwardObjectCallback() != null) {
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append("/*NOT POSSIBLE TO GENERATE CODE FOR OBJECT CALLBACK*/");
}
if (expectation.getHttpError() != null) {
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(".error(");
output.append(new HttpErrorToJavaSerializer().serialize(numberOfSpacesToIndent + 1, expectation.getHttpError()));
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output).append(")");
}
output.append(";");
}
return output.toString();
}
示例3: ExpectationDTO
import org.mockserver.mock.Expectation; //导入方法依赖的package包/类
public ExpectationDTO(Expectation expectation) {
if (expectation != null) {
HttpRequest httpRequest = expectation.getHttpRequest();
if (httpRequest != null) {
this.httpRequest = new HttpRequestDTO(httpRequest, httpRequest.getNot());
}
HttpResponse httpResponse = expectation.getHttpResponse();
if (httpResponse != null) {
this.httpResponse = new HttpResponseDTO(httpResponse);
}
HttpTemplate httpResponseTemplate = expectation.getHttpResponseTemplate();
if (httpResponseTemplate != null) {
this.httpResponseTemplate = new HttpTemplateDTO(httpResponseTemplate);
}
HttpClassCallback httpResponseClassCallback = expectation.getHttpResponseClassCallback();
if (httpResponseClassCallback != null) {
this.httpResponseClassCallback = new HttpClassCallbackDTO(httpResponseClassCallback);
}
HttpObjectCallback httpResponseObjectCallback = expectation.getHttpResponseObjectCallback();
if (httpResponseObjectCallback != null) {
this.httpResponseObjectCallback = new HttpObjectCallbackDTO(httpResponseObjectCallback);
}
HttpForward httpForward = expectation.getHttpForward();
if (httpForward != null) {
this.httpForward = new HttpForwardDTO(httpForward);
}
HttpTemplate httpForwardTemplate = expectation.getHttpForwardTemplate();
if (httpForwardTemplate != null) {
this.httpForwardTemplate = new HttpTemplateDTO(httpForwardTemplate);
}
HttpClassCallback httpForwardClassCallback = expectation.getHttpForwardClassCallback();
if (httpForwardClassCallback != null) {
this.httpForwardClassCallback = new HttpClassCallbackDTO(httpForwardClassCallback);
}
HttpObjectCallback httpForwardObjectCallback = expectation.getHttpForwardObjectCallback();
if (httpForwardObjectCallback != null) {
this.httpForwardObjectCallback = new HttpObjectCallbackDTO(httpForwardObjectCallback);
}
HttpOverrideForwardedRequest httpOverrideForwardedRequest = expectation.getHttpOverrideForwardedRequest();
if (httpOverrideForwardedRequest != null) {
this.httpOverrideForwardedRequest = new HttpOverrideForwardedRequestDTO(httpOverrideForwardedRequest);
}
HttpError httpError = expectation.getHttpError();
if (httpError != null) {
this.httpError = new HttpErrorDTO(httpError);
}
Times times = expectation.getTimes();
if (times != null) {
this.times = new org.mockserver.client.serialization.model.TimesDTO(times);
}
TimeToLive timeToLive = expectation.getTimeToLive();
if (timeToLive != null) {
this.timeToLive = new TimeToLiveDTO(timeToLive);
}
}
}