本文整理汇总了Java中au.com.dius.pact.consumer.dsl.PactDslWithProvider类的典型用法代码示例。如果您正苦于以下问题:Java PactDslWithProvider类的具体用法?Java PactDslWithProvider怎么用?Java PactDslWithProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PactDslWithProvider类属于au.com.dius.pact.consumer.dsl包,在下文中一共展示了PactDslWithProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configurationFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(provider="test_provider", consumer="test_consumer")
public PactFragment configurationFragment(PactDslWithProvider builder) {
return builder
.given("a serval exists")
.uponReceiving("a request for an serval")
.path("/animals/serval")
.method("GET")
.willRespondWith()
.headers(headers)
.status(200)
.body(
"{\n" +
"\"animals\": [\n" +
" {\n" +
" \"id\": 1,\n" +
" \"name\": \"サーバルちゃん\"\n" +
" }\n" +
"]\n" +
"}"
)
.toFragment();
}
示例2: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(consumer = "AuthenticationService")
public PactFragment createFragment(PactDslWithProvider pactDslWithProvider) throws JsonProcessingException {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
return pactDslWithProvider
.given("No customer Mike found")
.uponReceiving("a request to validate Mike")
.path("/rest/api/login/validate")
.method("POST")
.query("sessionId=" + sessionId)
.headers(headers)
.willRespondWith()
.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
.toFragment();
}
示例3: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(provider = "our_provider", consumer = "our_consumer")
public PactFragment createFragment(PactDslWithProvider builder) throws UnsupportedEncodingException {
PactDslJsonBody body = new PactDslJsonBody()
.stringType("test")
.stringType("valid_date", DateHelper.toString(DATE_TIME))
.eachLike("animals", 3)
.stringType("name", "Doggy")
.stringType("image", "dog")
.closeObject()
.closeArray()
.asBody();
return builder
.given("data count is > 0")
.uponReceiving("a request for json data")
.path("/provider.json")
.method("GET")
.query("valid_date=" + DateHelper.encodeDate(DATE_TIME))
.willRespondWith()
.status(200)
.headers(HEADERS)
.body(body)
.toFragment();
}
示例4: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(consumer = "AuthenticationService")
public PactFragment createFragment(PactDslWithProvider pactDslWithProvider) throws JsonProcessingException {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", MediaType.APPLICATION_FORM_URLENCODED);
return pactDslWithProvider
.given("Customer Sean is registered")
.uponReceiving("a request to validate Sean")
.path("/rest/api/login/validate")
.method("POST")
.query("sessionId=" + customerSessionInfo.getId())
.headers(headers)
.willRespondWith()
.status(200)
.body(objectMapper.writeValueAsString(customerSessionInfo), MediaType.APPLICATION_JSON)
.toFragment();
}
示例5: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(consumer = "UserService")
public PactFragment createFragment(PactDslWithProvider pactDslWithProvider) throws JsonProcessingException {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
return pactDslWithProvider
.given("Customer Sean is registered")
.uponReceiving("a request for Sean")
.path("/rest/api/customer/" + customerInfo.getId())
.method("GET")
.willRespondWith()
.headers(headers)
.status(200)
.body(objectMapper.writeValueAsString(customerInfo))
.toFragment();
}
示例6: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(consumer = "Manager")
public PactFragment createFragment(PactDslWithProvider pactDslWithProvider) throws JsonProcessingException {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", MediaType.TEXT_PLAIN_VALUE);
return pactDslWithProvider
.given("User Jack is unauthorized")
.uponReceiving("a request to access from Jack")
.path("/rest/validate")
.body(objectMapper.writeValueAsString(new Token(token)), APPLICATION_JSON)
.method("POST")
.willRespondWith()
.headers(headers)
.status(HttpStatus.FORBIDDEN.value())
.toFragment();
}
开发者ID:ServiceComb,项目名称:ServiceComb-Company-WorkShop,代码行数:17,代码来源:AuthenticationServiceFailedTest.java
示例7: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(consumer = "Manager")
public PactFragment createFragment(PactDslWithProvider pactDslWithProvider) throws JsonProcessingException {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", MediaType.TEXT_PLAIN_VALUE);
return pactDslWithProvider
.given("User Sean is authorized")
.uponReceiving("a request to access from Sean")
.path("/rest/validate")
.body(objectMapper.writeValueAsString(new Token(token)), APPLICATION_JSON)
.method("POST")
.willRespondWith()
.headers(headers)
.status(HttpStatus.OK.value())
.body(username)
.toFragment();
}
开发者ID:ServiceComb,项目名称:ServiceComb-Company-WorkShop,代码行数:18,代码来源:AuthenticationServiceHappyTest.java
示例8: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(provider = "test_provider", consumer = "test_consumer")
public RequestResponsePact createFragment(PactDslWithProvider builder) {
Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/json");
return builder
.given("test state")
.uponReceiving("ConsumerTest test interaction")
.path("/")
.method("GET")
.willRespondWith()
.status(200)
.headers(header)
.bodyWithSingleQuotes(("{'responsetest': true, 'name': 'harry'}"))
.toPact();
}
示例9: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
public RequestResponsePact createFragment(PactDslWithProvider builder) {
Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/json");
return builder
.given("test state", "name", "Alexandra")
.uponReceiving("ConsumerTest test interaction")
.path("/")
.method("GET")
.willRespondWith()
.status(200)
.headers(header)
.bodyWithSingleQuotes("{'responsetest': true, 'name': 'harry'}")
.toPact();
}
示例10: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(consumer = "UserService")
public PactFragment createFragment(PactDslWithProvider pactDslWithProvider) {
return pactDslWithProvider
.given("No customer Mike found")
.uponReceiving("a request for Mike")
.path("/rest/api/customer/mike")
.method("GET")
.willRespondWith()
.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
.toFragment();
}
示例11: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(consumer = "RemoteCustomerLoader")
public PactFragment createFragment(PactDslWithProvider pactDslWithProvider) throws JsonProcessingException {
return pactDslWithProvider
.given("Remote customer loader is available")
.uponReceiving("a request to load customers")
.path("/rest/info/loader/load")
.query("number=5")
.method("POST")
.willRespondWith()
.status(HttpStatus.SC_NO_CONTENT)
.toFragment();
}
示例12: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(consumer = "RemoteCustomerLoader")
public PactFragment createFragment(PactDslWithProvider pactDslWithProvider) {
return pactDslWithProvider
.given("Remote customer loader is not available")
.uponReceiving("a request to load customers")
.path("/rest/info/loader/load")
.query("number=5")
.method("POST")
.willRespondWith()
.status(500)
.toFragment();
}
示例13: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(provider = "our_provider", consumer = "our_consumer")
public PactFragment createFragment(PactDslWithProvider builder) throws UnsupportedEncodingException {
return builder
.given("data count is == 0")
.uponReceiving("a request for json data")
.path("/provider.json")
.method("GET")
.query("valid_date=" + DateHelper.encodeDate(DATE_TIME))
.willRespondWith()
.status(404)
.toFragment();
}
示例14: createFragment
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(provider = "our_provider", consumer = "our_consumer")
public PactFragment createFragment(PactDslWithProvider builder) throws UnsupportedEncodingException {
return builder
.given("data count is > 0")
.uponReceiving("a request with an missing date parameter")
.path("/provider.json")
.method("GET")
.willRespondWith()
.status(400)
.body("valid_date is required")
.toFragment();
}
示例15: validatePactSignature
import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
private void validatePactSignature(Method method) {
boolean hasValidPactSignature =
RequestResponsePact.class.isAssignableFrom(method.getReturnType())
&& method.getParameterTypes().length == 1
&& method.getParameterTypes()[0].isAssignableFrom(PactDslWithProvider.class);
if (!hasValidPactSignature) {
throw new UnsupportedOperationException("Method " + method.getName() +
" does not conform required method signature 'public PactFragment xxx(PactDslWithProvider builder)'");
}
}