本文整理汇总了Java中com.github.tomakehurst.wiremock.extension.Parameters类的典型用法代码示例。如果您正苦于以下问题:Java Parameters类的具体用法?Java Parameters怎么用?Java Parameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Parameters类属于com.github.tomakehurst.wiremock.extension包,在下文中一共展示了Parameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: transform
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
FileSource files, Parameters parameters) {
MockParameters params = (MockParameters) parameters.get(UnitStackTest.MOCK_PARAMS);
Map<String, String> body = new HashMap<>();
String method = request.getMethod().getName();
byte[] fileContent = null;
body.put(PARAMETER_URL_NAME, request.getAbsoluteUrl());
body.put(PARAMETER_METHOD, method);
if (method.equals("GET")) {
body.put(ACTION, StringUtils.substringAfter(request.getAbsoluteUrl(), "?"));
} else {
body.put(PARAMETER_RESPONSE_XML, request.getBodyAsString());
fileContent = request.getBody();
}
body.putAll(getHeaders(request));
MockResponse response = s3Responder.createResponse(
new MockRequest(body, params, utils).withBuckets(buckets).withFileContent(fileContent));
return createResponse(response);
}
开发者ID:daflockinger,项目名称:unitstack,代码行数:23,代码来源:S3RequestTransformer.java
示例2: transform
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request,
ResponseDefinition responseDefinition,
FileSource files,
Parameters parameters) {
ResponseDefinitionBuilder builder = new ResponseDefinitionBuilder().like(responseDefinition);
String templatePath = responseDefinition.getBodyFileName();
if (templatePath != null && templatePath.contains(".template")) {
try {
Map scope = new ResponseScope(session, new HashMap(this.config), RequestReader.read(request));
responseWriter = responseWriter == null ? new ResponseWriter(files.getPath()) : responseWriter;
new BeforeBlock().run(responseDefinition, scope);
responseWriter.writeTo(builder, scope, templatePath);
} catch (Exception e) {
String errorMessage = "************* Jeyson Error *******************" + System.getProperty("line.separator");
errorMessage += e.getMessage() + System.getProperty("line.separator");
System.err.println(errorMessage);
e.printStackTrace();
}
}
return builder.build();
}
开发者ID:nishants,项目名称:wirestub,代码行数:27,代码来源:JeysonWiremock.java
示例3: transform
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request,
ResponseDefinition responseDefinition,
FileSource files,
Parameters parameters) {
ResponseDefinitionBuilder builder = new ResponseDefinitionBuilder().like(responseDefinition);
String templatePath = responseDefinition.getBodyFileName();
if (templatePath != null) {
try {
Map scope = new ResponseScope(session, new HashMap(this.config), RequestReader.read(request));
responseWriter = responseWriter == null ? new ResponseWriter(files.getPath()) : responseWriter;
new BeforeBlock().run(responseDefinition, scope);
responseWriter.writeTo(builder, scope, templatePath);
} catch (Exception e) {
String errorMessage = "************* Jeyson Error *******************" + System.getProperty("line.separator");
errorMessage += e.getMessage() + System.getProperty("line.separator");
System.err.println(errorMessage);
e.printStackTrace();
}
}
return builder.build();
}
开发者ID:nishants,项目名称:wirestub,代码行数:27,代码来源:JeysoneWiremockException.java
示例4: transform
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
@Override
public ResponseDefinition transform(final Request request,
final ResponseDefinition responseDefinition, final FileSource files,
final Parameters parameters) {
if (responseDefinition.specifiesBodyFile() && templateDeclared(responseDefinition)) {
this.fileSource = files;
final VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.init();
final ToolManager toolManager = new ToolManager();
toolManager.setVelocityEngine(velocityEngine);
context = toolManager.createContext();
addBodyToContext(request.getBodyAsString());
addHeadersToContext(request.getHeaders());
context.put("requestAbsoluteUrl", request.getAbsoluteUrl());
context.put("requestUrl", request.getUrl());
context.put("requestMethod", request.getMethod());
final String body = getRenderedBody(responseDefinition);
return ResponseDefinitionBuilder.like(responseDefinition).but()
.withBody(body)
.build();
} else {
return responseDefinition;
}
}
开发者ID:adamyork,项目名称:wiremock-velocity-transformer,代码行数:25,代码来源:VelocityResponseTransformer.java
示例5: startRecording
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
public static void startRecording() {
wireMockServer.startRecording(recordSpec()
.forTarget(prop.getTargetUrl())
.captureHeader("Accept")
.captureHeader("Content-Type", true)
.extractBinaryBodiesOver(0)
.extractTextBodiesOver(0)
.makeStubsPersistent(true)
.transformers("modify-response-header")
.transformerParameters(Parameters.one("headerValue", "123"))
.matchRequestBodyWithEqualToJson(false, true));
}
开发者ID:Sybit-Education,项目名称:airtable.java,代码行数:14,代码来源:WireMockBaseTest.java
示例6: RootConfigHandler
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
public RootConfigHandler(final Request request, final Parameters transformerParameters) throws WireMockCsvException {
this.request = request;
this.requestParams = RequestTemplateModel.from(request).getQuery();
this.transformerParameters = transformerParameters;
@SuppressWarnings("unchecked")
final Map<String, Map<String, Object>> customParametersConfig =
(Map<String, Map<String, Object>>) this.transformerParameters.get("customParameters");
this.initCustomParameters(customParametersConfig);
}
开发者ID:massamany,项目名称:WireMockCsv,代码行数:10,代码来源:ConfigHandler.java
示例7: getQueriesConfig
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
private Map<String, Object> getQueriesConfig(final Parameters parameters) {
final Map<String, Object> queries = new HashMap<>(this.config.getGlobalConfig());
this.putConfigParameter(parameters, queries, "structure");
this.putConfigParameter(parameters, queries, "conditionQuery");
this.putConfigParameter(parameters, queries, "conditions");
this.putConfigParameter(parameters, queries, "query");
this.putConfigParameter(parameters, queries, "subqueries");
this.putConfigParameter(parameters, queries, "mask");
this.putConfigParameter(parameters, queries, "aliases");
this.putConfigParameter(parameters, queries, "resultType");
this.putConfigParameter(parameters, queries, "noLines");
return queries;
}
开发者ID:massamany,项目名称:WireMockCsv,代码行数:14,代码来源:WireMockCsv.java
示例8: transform
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
FileSource files, Parameters parameters) {
MockParameters params = (MockParameters) parameters.get(UnitStackTest.MOCK_PARAMS);
Map<String, String> body = utils.queryStringToMap(request.getBodyAsString());
MockResponse response =
snsResponder.createResponse(new MockRequest(body, params, utils).withTopics(topics));
return new ResponseDefinitionBuilder().withBody(response.getBody())
.withStatus(response.getStatus()).build();
}
开发者ID:daflockinger,项目名称:unitstack,代码行数:12,代码来源:SnsRequestTransformer.java
示例9: transform
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
@Override
public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition,
FileSource files, Parameters parameters) {
MockParameters params = (MockParameters) parameters.get(UnitStackTest.MOCK_PARAMS);
Map<String, String> body = new HashMap<>(utils.queryStringToMap(request.getBodyAsString()));
body.put(PARAMETER_URL_NAME, request.getUrl());
MockResponse response =
sqsResponder.createResponse(new MockRequest(body, params, utils).withQueues(queues));
return new ResponseDefinitionBuilder().withBody(response.getBody())
.withStatus(response.getStatus()).build();
}
开发者ID:daflockinger,项目名称:unitstack,代码行数:14,代码来源:SqsRequestTransformer.java
示例10: run
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
public void run(ResponseDefinition responseDefinition, Map scope) throws URISyntaxException, NoSuchMethodException, IOException, ScriptException {
Parameters transformers = responseDefinition.getTransformerParameters();
if(transformers != null && transformers.get("before") != null){
String[] beforeBlock = ((List<String>) responseDefinition.getTransformerParameters().get("before")).toArray(new String[0]);
expressions.eval(beforeBlock, scope);
}
}
开发者ID:nishants,项目名称:wirestub,代码行数:8,代码来源:BeforeBlock.java
示例11: getRequestConfigHandler
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
public RequestConfigHandler getRequestConfigHandler(final Request request, final Parameters parameters) throws WireMockCsvException {
return new RootConfigHandler(request, parameters);
}
开发者ID:massamany,项目名称:WireMockCsv,代码行数:4,代码来源:ConfigHandler.java
示例12: getTransformerParameters
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
@Override
public Parameters getTransformerParameters() {
return this.transformerParameters;
}
开发者ID:massamany,项目名称:WireMockCsv,代码行数:5,代码来源:ConfigHandler.java
示例13: transform
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
@Override
public Response transform(final Request request, final Response response, final FileSource files,
final Parameters parameters) {
try {
final Map<String, Object> queries = this.getQueriesConfig(parameters);
final RequestConfigHandler requestConfig = this.config.getRequestConfigHandler(request, parameters);
final Object structure = queries.get("structure");
String jsonStructure;
if (structure == null) {
jsonStructure = "${WireMockCsv}";
} else {
jsonStructure = structure instanceof String ? (String) structure : this.jsonConverter.convertObjectToJson(structure);
}
final QueryResults qr = this.executeQueries(requestConfig, queries);
final Builder builder = Response.Builder.like(response).but();
String body = jsonStructure
.replace("\"${WireMockCsv}\"", "${WireMockCsv}")
.replace("${WireMockCsv}", this.jsonConverter.convertToJson(qr));
if (qr.getLines().isEmpty() && queries.containsKey("noLines")) {
@SuppressWarnings("unchecked")
final
Map<String, Object> noLines = (Map<String, Object>) queries.get("noLines");
if (noLines.containsKey("status")) {
builder.status((Integer) noLines.get("status"));
}
if (noLines.containsKey("statusMessage")) {
builder.statusMessage((String) noLines.get("statusMessage"));
}
if (noLines.containsKey("response")) {
final Object responseNotFound = noLines.get("response");
body = responseNotFound instanceof String ? (String) responseNotFound : this.jsonConverter.convertObjectToJson(responseNotFound);
}
}
builder.body(this.jsonConverter.formatJson(body));
return builder.build();
} catch (final WireMockCsvException e) {
WireMockConfiguration.wireMockConfig().notifier().error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
开发者ID:massamany,项目名称:WireMockCsv,代码行数:43,代码来源:WireMockCsv.java
示例14: putConfigParameter
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
private void putConfigParameter(final Parameters parameters, final Map<String, Object> queries, final String key) {
if (parameters.containsKey(key)) {
queries.put(key, parameters.get(key));
}
}
开发者ID:massamany,项目名称:WireMockCsv,代码行数:6,代码来源:WireMockCsv.java
示例15: transform
import com.github.tomakehurst.wiremock.extension.Parameters; //导入依赖的package包/类
@Override
public Response transform(Request request, Response response, FileSource files, Parameters parameters) {
return Response.Builder.like(response).but()
.body("wiremock-maven-plugin-transformed-response-body")
.build();
}
开发者ID:deliverymind,项目名称:wiremock-maven-plugin,代码行数:7,代码来源:SampleResponseTransformer.java
注:本文中的com.github.tomakehurst.wiremock.extension.Parameters类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论