本文整理汇总了Java中org.mockserver.model.Parameter类的典型用法代码示例。如果您正苦于以下问题:Java Parameter类的具体用法?Java Parameter怎么用?Java Parameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Parameter类属于org.mockserver.model包,在下文中一共展示了Parameter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getUsers
import org.mockserver.model.Parameter; //导入依赖的package包/类
private void getUsers(MockServerClient mockServerClient) {
mockServerClient
.dumpToLog()
.when(
HttpRequest.request()
.withMethod("GET")
.withPath("/user")
.withHeader(Header.header("X-SESSION-ID", "020835c7-cf7e-4ba5-b117-4402e5d79079"))
.withQueryStringParameter(Parameter.param("byUsername", "jdoe")),
Times.unlimited()
).respond(
HttpResponse.response()
.withStatusCode(200)
.withBody("{ \"users\" : [{ \"name\" : \"John Doe\" }] }")
);
}
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:18,代码来源:MockServerInitializationClass.java
示例2: getRoleUsers
import org.mockserver.model.Parameter; //导入依赖的package包/类
private void getRoleUsers(MockServerClient mockServerClient) {
mockServerClient
.dumpToLog()
.when(
HttpRequest.request()
.withMethod("GET")
.withPath("/user/role")
.withQueryStringParameter(Parameter.param("byRole", "vanessa")),
Times.unlimited()
).respond(
HttpResponse.response()
.withStatusCode(200)
.withBody("{ \"users\" : [] }")
);
}
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:17,代码来源:MockServerInitializationClass.java
示例3: addSentimentADM
import org.mockserver.model.Parameter; //导入依赖的package包/类
private void addSentimentADM(String baseURL, MockServerClient mockServerClient) {
try (InputStream is = getClass().getClassLoader().getResourceAsStream("mock_responses/sentiment_adm_response.json")) {
String response = getStringFromResource(is);
mockServerClient.when(HttpRequest.request()
.withMethod("POST")
.withPath(baseURL + "sentiment").withQueryStringParameter(new Parameter("output", "rosette")))
.respond(HttpResponse.response()
.withStatusCode(200)
.withHeaders(
new Header(HttpHeaders.CONTENT_TYPE, "application/json")
)
.withBody(response));
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
开发者ID:rosette-api,项目名称:rosette-elasticsearch-plugin,代码行数:17,代码来源:MockRosetteInitialization.java
示例4: mailShouldStillBeDeliveredWhenClassificationFails
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void mailShouldStillBeDeliveredWhenClassificationFails() throws Exception {
String recipientTo = "[email protected]" + DEFAULT_DOMAIN;
String response = "{}";
mockServerClient
.when(HttpRequest.request()
.withMethod("POST")
.withPath("/email/classification/predict")
.withQueryStringParameter(new Parameter("recipients", "[email protected]")),
Times.exactly(1))
.respond(HttpResponse.response(response));
DataProbe dataProbe = jamesServer.getProbe(DataProbeImpl.class);
dataProbe.addDomain(DEFAULT_DOMAIN);
String from = "[email protected]" + DEFAULT_DOMAIN;
dataProbe.addUser(from, PASSWORD);
dataProbe.addUser(recipientTo, PASSWORD);
jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, recipientTo, "INBOX");
try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, DEFAULT_DOMAIN);
IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST_IP, IMAP_PORT)) {
messageSender.sendMessage(from, recipientTo);
calmlyAwait.until(messageSender::messageHasBeenSent);
calmlyAwait.until(() -> imapMessageReader.userReceivedMessage(recipientTo, PASSWORD));
}
}
开发者ID:linagora,项目名称:openpaas-mailets,代码行数:27,代码来源:ClassificationIntegrationTest.java
示例5: getUsersWithSystem
import org.mockserver.model.Parameter; //导入依赖的package包/类
private void getUsersWithSystem(MockServerClient mockServerClient) {
mockServerClient
.dumpToLog()
.when(
HttpRequest.request()
.withMethod("GET")
.withPath("/user")
.withHeader(Header.header("X-SESSION-ID", "020835c7-cf7e-4ba5-b117-4402e5d79079"))
.withQueryStringParameter(Parameter.param("byUsername", "bbelcher"))
.withQueryStringParameter(Parameter.param("bySystem", "email")),
Times.unlimited()
).respond(
HttpResponse.response()
.withStatusCode(200)
.withBody("{ \"users\" : [{ \"name\" : \"John Doe\" },{ \"name\" : \"Bob Belcher\" }] }")
);
}
开发者ID:kenzanlabs,项目名称:bowtie,代码行数:19,代码来源:MockServerInitializationClass.java
示例6: shouldReturnErrorsForBrokenSecuritySpecifications
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void shouldReturnErrorsForBrokenSecuritySpecifications() {
org.mockserver.model.Header authorizationHeader = new org.mockserver.model.Header(HttpHeaders.AUTHORIZATION, "Basic 1234", "wrong");
Parameter tokenParameter = new Parameter("token", "123456", "i_am_text");
when(expectation.getRequestHeader(HttpHeaders.AUTHORIZATION)).thenReturn(Optional.of(authorizationHeader));
when(expectation.getQueryParameter("token")).thenReturn(Optional.of(tokenParameter));
ValidationErrors errors = new RequestSecurityValidator(expectation).validate();
assertThat(errors.isInError()).isTrue();
assertThat(errors.getMessages())
.hasSize(4)
.contains(
"[ security ] [ header ] [ basic ] Only one value allowed for security parameters but multiple found.",
"[ security ] [ header ] [ basic ] Value of [ wrong ] does not meet API requirements.",
"[ security ] [ query ] [ query-token ] Only one value allowed for security parameters but multiple found.",
"[ security ] [ query ] [ query-token ] Value of [ i_am_text ] does not meet API requirements."
);
}
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:21,代码来源:RequestSecurityValidatorTest.java
示例7: shouldLoadSingleBook
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void shouldLoadSingleBook() throws Exception {
// when
MvcResult response = mockMvc.perform(get("/book/1").accept(MediaType.TEXT_HTML))
.andExpect(status().isOk())
.andExpect(content().contentType("text/html; charset=utf-8"))
.andReturn();
// then
BookPage bookPage = new BookPage(response);
bookPage.containsBook(bookServer.getBooksDB().get("1"));
proxy.verify(
request()
.withPath("/get_book")
.withQueryStringParameter(
new Parameter("id", "1")
),
exactly(1)
);
}
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:21,代码来源:BooksPageEndToEndIntegrationTest.java
示例8: shouldMatchMatchingString
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void shouldMatchMatchingString() {
assertTrue(new ParameterStringMatcher(new MockServerLogger(), new Parameters(
new Parameter("parameterOneName", "parameterOneValueOne", "parameterOneValueTwo"),
new Parameter("parameterTwoName", "parameterTwoValue")
)).matches(null, "" +
"parameterOneName=parameterOneValueOne" +
"¶meterOneName=parameterOneValueTwo" +
"¶meterTwoName=parameterTwoValue"));
assertTrue(new ParameterStringMatcher(new MockServerLogger(), new Parameters(
new Parameter("parameter.*", "parameter.*")
)).matches(null, "" +
"parameterOneName=parameterOneValueOne" +
"¶meterOneName=parameterOneValueTwo" +
"¶meterTwoName=parameterTwoValue"));
}
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:18,代码来源:ParameterStringMatcherTest.java
示例9: shouldMatchMatchingParameter
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void shouldMatchMatchingParameter() {
assertTrue(new MultiValueMapMatcher(new MockServerLogger(), new Parameters().withEntries(
new Parameter("parameterOneName", "parameterOneValueOne", "parameterOneValueTwo"),
new Parameter("parameterTwoName", "parameterTwoValue")
)).matches(null,
new Parameters().withEntries(
new Parameter("parameterOneName", "parameterOneValueOne", "parameterOneValueTwo"),
new Parameter("parameterTwoName", "parameterTwoValue")
)
));
assertTrue(new MultiValueMapMatcher(new MockServerLogger(), new Parameters().withEntries(
new Parameter("parameter.*", "parameter.*")
)).matches(
null,
new Parameters().withEntries(
new Parameter("parameterOneName", "parameterOneValueOne", "parameterOneValueTwo"),
new Parameter("parameterTwoName", "parameterTwoValue")
)
));
}
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:23,代码来源:QueryParameterMatcherTest.java
示例10: shouldMatchMatchingParameterWithOnlyParameterForEmptyList
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void shouldMatchMatchingParameterWithOnlyParameterForEmptyList() {
assertTrue(new MultiValueMapMatcher(new MockServerLogger(), new Parameters()).matches(
null,
new Parameters().withEntries(
new Parameter("parameterThree", "parameterThreeValueOne")
)
));
assertFalse(new MultiValueMapMatcher(new MockServerLogger(), new Parameters().withEntries(
new Parameter("parameterThree", "parameterThreeValueOne")
)).matches(null, new Parameters()));
assertTrue(new MultiValueMapMatcher(new MockServerLogger(), new Parameters().withEntries(
new Parameter(not("parameterThree"), not("parameterThreeValueOne"))
)).matches(null, new Parameters()));
}
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:18,代码来源:QueryParameterMatcherTest.java
示例11: shouldReturnCorrectObjectFromStaticBuilder
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void shouldReturnCorrectObjectFromStaticBuilder() {
assertThat(params(
new Parameter("some", "value")
),
is(
new ParameterBody(
new Parameter("some", "value")
)
)
);
assertThat(params(Arrays.asList(
new Parameter("some", "value")
)),
is(
new ParameterBody(
new Parameter("some", "value")
)
)
);
}
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:22,代码来源:ParameterBodyDTOTest.java
示例12: classificationShouldCorrectlyAuthenticateToDataRestApi
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void classificationShouldCorrectlyAuthenticateToDataRestApi() throws Exception {
String recipientTo = "[email protected]" + DEFAULT_DOMAIN;
String response = "{\"results\":" +
"{\"" + recipientTo + "\":{" +
" \"mailboxId\":\"cfe49390-f391-11e6-88e7-ddd22b16a7b9\"," +
" \"mailboxName\":\"JAMES\"," +
" \"confidence\":50.07615280151367}" +
"}," +
"\"errors\":{}}";
mockServerClient
.when(HttpRequest.request()
.withHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString("username:password".getBytes()))
.withMethod("POST")
.withPath("/email/classification/predict")
.withQueryStringParameter(new Parameter("recipients", "[email protected]")),
Times.exactly(1))
.respond(HttpResponse.response(response));
DataProbe dataProbe = jamesServer.getProbe(DataProbeImpl.class);
dataProbe.addDomain(DEFAULT_DOMAIN);
String from = "[email protected]" + DEFAULT_DOMAIN;
dataProbe.addUser(from, PASSWORD);
dataProbe.addUser(recipientTo, PASSWORD);
jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, recipientTo, "INBOX");
try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, DEFAULT_DOMAIN);
IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST_IP, IMAP_PORT)) {
messageSender.sendMessage(from, recipientTo);
calmlyAwait.until(messageSender::messageHasBeenSent);
calmlyAwait.until(() -> imapMessageReader.userReceivedMessage(recipientTo, PASSWORD));
calmlyAwait.until(() -> imapMessageReader.readFirstMessageHeadersInInbox(recipientTo, PASSWORD)
.contains("X-Classification-Guess: {" +
"\"mailboxId\":\"cfe49390-f391-11e6-88e7-ddd22b16a7b9\"," +
"\"mailboxName\":\"JAMES\"," +
"\"confidence\":50.07615280151367}"));
}
}
开发者ID:linagora,项目名称:openpaas-mailets,代码行数:40,代码来源:ClassificationIntegrationTest.java
示例13: classificationShouldCustomizeMailHeaders
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void classificationShouldCustomizeMailHeaders() throws Exception {
String recipientTo = "[email protected]" + DEFAULT_DOMAIN;
String response = "{\"results\":" +
"{\"" + recipientTo + "\":{" +
" \"mailboxId\":\"cfe49390-f391-11e6-88e7-ddd22b16a7b9\"," +
" \"mailboxName\":\"JAMES\"," +
" \"confidence\":50.07615280151367}" +
"}," +
"\"errors\":{}}";
mockServerClient
.when(HttpRequest.request()
.withMethod("POST")
.withPath("/email/classification/predict")
.withQueryStringParameter(new Parameter("recipients", "[email protected]")),
Times.exactly(1))
.respond(HttpResponse.response(response));
DataProbe dataProbe = jamesServer.getProbe(DataProbeImpl.class);
dataProbe.addDomain(DEFAULT_DOMAIN);
String from = "[email protected]" + DEFAULT_DOMAIN;
dataProbe.addUser(from, PASSWORD);
dataProbe.addUser(recipientTo, PASSWORD);
jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, recipientTo, "INBOX");
try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, DEFAULT_DOMAIN);
IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST_IP, IMAP_PORT)) {
messageSender.sendMessage(from, recipientTo);
calmlyAwait.until(messageSender::messageHasBeenSent);
calmlyAwait.until(() -> imapMessageReader.userReceivedMessage(recipientTo, PASSWORD));
calmlyAwait.until(() -> imapMessageReader.readFirstMessageHeadersInInbox(recipientTo, PASSWORD)
.contains("X-Classification-Guess: {" +
"\"mailboxId\":\"cfe49390-f391-11e6-88e7-ddd22b16a7b9\"," +
"\"mailboxName\":\"JAMES\"," +
"\"confidence\":50.07615280151367}"));
}
}
开发者ID:linagora,项目名称:openpaas-mailets,代码行数:39,代码来源:ClassificationIntegrationTest.java
示例14: notNullQueryParamsFrom
import org.mockserver.model.Parameter; //导入依赖的package包/类
private Parameter[] notNullQueryParamsFrom(String reference, String email, String state, String cardBrand, String fromDate, String toDate, String page, String displaySize) {
List<Parameter> params = newArrayList();
if (isNotBlank(reference)) {
params.add(Parameter.param(REFERENCE_KEY, reference));
}
if (isNotBlank(email)) {
params.add(Parameter.param(EMAIL_KEY, email));
}
if (isNotBlank(state)) {
params.add(Parameter.param(STATE_KEY, state));
}
if (isNotBlank(cardBrand)) {
params.add(Parameter.param(CARD_BRAND_KEY, CARD_BRAND.toLowerCase()));
}
if (isNotBlank(fromDate)) {
params.add(Parameter.param(FROM_DATE_KEY, fromDate));
}
if (isNotBlank(toDate)) {
params.add(Parameter.param(TO_DATE_KEY, toDate));
}
if (isNotBlank(page)) {
params.add(Parameter.param("page", page));
}
if (isNotBlank(displaySize)) {
params.add(Parameter.param("display_size", displaySize));
}
return params.toArray(new Parameter[0]);
}
开发者ID:alphagov,项目名称:pay-publicapi,代码行数:29,代码来源:ConnectorMockClient.java
示例15: shouldReturnErrorIfQueryParameterIsNotRepeatableButMultipleValuesProvided
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void shouldReturnErrorIfQueryParameterIsNotRepeatableButMultipleValuesProvided() {
Parameter parameter = new Parameter("ttl", "1", "2");
when(expectation.getQueryParameter("ttl")).thenReturn(Optional.of(parameter));
when(action.getQueryParameters()).thenReturn(queryParameter(true, false));
ValidationErrors errors = new RequestQueryParametersValidator(expectation).validate();
assertThat(errors.isInError()).isTrue();
assertThat(errors.getMessages())
.hasSize(1)
.contains("[ request ] [ query ] [ ttl ] Only one value allowed but multiple values provided.");
}
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:14,代码来源:RequestQueryParametersValidatorTest.java
示例16: shouldReturnErrorIfQueryParameterDoesNotMeetRulesOfParameter
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void shouldReturnErrorIfQueryParameterDoesNotMeetRulesOfParameter() {
Parameter parameter = new Parameter("ttl", "i_am_text");
when(expectation.getQueryParameter("ttl")).thenReturn(Optional.of(parameter));
when(action.getQueryParameters()).thenReturn(queryParameter(true, false));
ValidationErrors errors = new RequestQueryParametersValidator(expectation).validate();
assertThat(errors.isInError()).isTrue();
assertThat(errors.getMessages())
.hasSize(1)
.contains("[ request ] [ query ] [ ttl ] Value of [ i_am_text ] does not meet API requirements.");
}
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:15,代码来源:RequestQueryParametersValidatorTest.java
示例17: testGetReviewComments
import org.mockserver.model.Parameter; //导入依赖的package包/类
/**
* Tests that getReviewComments method correctly receives 1 page of review comments
* returned from a MockServer that emulates GitHub API service.
*/
@Test
public void testGetReviewComments() throws IOException {
MockServerClient mockServer = ClientAndServer.startClientAndServer(8888);
String sampleComments = TestUtils.readFileFromResource(this, "tests/ReviewCommentsSample.json");
mockServer.when(
request()
.withPath(TestUtils.API_PREFIX + "/repos/hubturbo/hubturbo/pulls/1125/comments")
.withQueryStringParameters(
new Parameter("per_page", "100"),
new Parameter("page", "1")
)
).respond(response().withBody(sampleComments));
GitHubClient client = new GitHubClient("localhost", 8888, "http");
PullRequestServiceEx service = new PullRequestServiceEx(client);
Type listOfComments = new TypeToken<List<ReviewComment>>() {
}.getType();
List<ReviewComment> expectedComments = new Gson().fromJson(sampleComments, listOfComments);
List<ReviewComment> actualComments = service.getReviewComments(
RepositoryId.createFromId("hubturbo/hubturbo"), 1125);
assertEquals(expectedComments.size(), actualComments.size());
Comparator<ReviewComment> comparator = (a, b) -> (int) (a.getId() - b.getId());
Collections.sort(expectedComments, comparator);
Collections.sort(actualComments, comparator);
for (int i = 0; i < expectedComments.size(); i++) {
assertEquals(expectedComments.get(i).getId(), actualComments.get(i).getId());
}
mockServer.stop();
}
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:41,代码来源:PullRequestServiceExTests.java
示例18: serialize
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Override
public String serialize(int numberOfSpacesToIndent, Parameter parameter) {
StringBuilder output = new StringBuilder();
output.append(NEW_LINE).append(Strings.padStart("", numberOfSpacesToIndent * INDENT_SIZE, ' '));
output.append("new Parameter(").append(NottableStringToJavaSerializer.serializeNottableString(parameter.getName()));
for (NottableString value : parameter.getValues()) {
output.append(", ").append(NottableStringToJavaSerializer.serializeNottableString(value));
}
output.append(")");
return output.toString();
}
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:12,代码来源:ParameterToJavaSerializer.java
示例19: serializeAsJava
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Override
public String serializeAsJava(int numberOfSpacesToIndent, List<Parameter> parameters) {
StringBuilder output = new StringBuilder();
for (int i = 0; i < parameters.size(); i++) {
output.append(serialize(numberOfSpacesToIndent, parameters.get(i)));
if (i < (parameters.size() - 1)) {
output.append(",");
}
}
return output.toString();
}
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:12,代码来源:ParameterToJavaSerializer.java
示例20: shouldNotMatchMatchingStringWhenNotApplied
import org.mockserver.model.Parameter; //导入依赖的package包/类
@Test
public void shouldNotMatchMatchingStringWhenNotApplied() {
// given
assertTrue(new ParameterStringMatcher(new MockServerLogger(), new Parameters(
new Parameter("parameterOneName", "parameterOneValueOne", "parameterOneValueTwo"),
new Parameter("parameterTwoName", "parameterTwoValue")
)).matches(null, "" +
"parameterOneName=parameterOneValueOne" +
"¶meterOneName=parameterOneValueTwo" +
"¶meterTwoName=parameterTwoValue"));
// then - not matcher
assertFalse(NotMatcher.not(new ParameterStringMatcher(new MockServerLogger(), new Parameters(
new Parameter("parameterOneName", "parameterOneValueOne", "parameterOneValueTwo"),
new Parameter("parameterTwoName", "parameterTwoValue")
))).matches(null, "" +
"parameterOneName=parameterOneValueOne" +
"¶meterOneName=parameterOneValueTwo" +
"¶meterTwoName=parameterTwoValue"));
// and - not parameter
assertFalse(new ParameterStringMatcher(new MockServerLogger(), new Parameters(
new Parameter("parameterOneName", "parameterOneValueOne", "parameterOneValueTwo"),
new Parameter(not("parameterTwoName"), not("parameterTwoValue"))
)).matches(null, "" +
"parameterOneName=parameterOneValueOne" +
"¶meterOneName=parameterOneValueTwo" +
"¶meterTwoName=parameterTwoValue"));
// and - not parameter
assertTrue(NotMatcher.not(new ParameterStringMatcher(new MockServerLogger(), new Parameters(
new Parameter("parameterOneName", "parameterOneValueOne", "parameterOneValueTwo"),
new Parameter(not("parameterTwoName"), not("parameterTwoValue"))
))).matches(null, "" +
"parameterOneName=parameterOneValueOne" +
"¶meterOneName=parameterOneValueTwo" +
"¶meterTwoName=parameterTwoValue"));
}
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:39,代码来源:ParameterStringMatcherTest.java
注:本文中的org.mockserver.model.Parameter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论