本文整理汇总了Java中au.com.dius.pact.model.PactFragment类的典型用法代码示例。如果您正苦于以下问题:Java PactFragment类的具体用法?Java PactFragment怎么用?Java PactFragment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PactFragment类属于au.com.dius.pact.model包,在下文中一共展示了PactFragment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: configurationFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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();
}
开发者ID:azusa,项目名称:pact-jvm-example,代码行数:23,代码来源:AnimalServiceClient.java
示例2: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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();
}
开发者ID:WillemJiang,项目名称:acmeair,代码行数:17,代码来源:AuthenticationCommandValidationFailedTest.java
示例3: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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();
}
开发者ID:DiUS,项目名称:pact-workshop-android,代码行数:25,代码来源:ServicePactTest.java
示例4: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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();
}
开发者ID:WillemJiang,项目名称:acmeair,代码行数:18,代码来源:AuthenticationCommandValidationTest.java
示例5: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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();
}
开发者ID:WillemJiang,项目名称:acmeair,代码行数:17,代码来源:UserCommandTest.java
示例6: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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.model.PactFragment; //导入依赖的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.model.PactFragment; //导入依赖的package包/类
@Pact(state = "FortuneState", provider = "FortuneService", consumer = "FortuneUi")
public PactFragment createFragment(ConsumerPactBuilder.PactDslWithProvider.PactDslWithState builder) {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json;charset=UTF-8");
PactDslJsonBody responseBody = new PactDslJsonBody()
.numberType("id")
.stringType("text");
return builder.uponReceiving("a request for a random fortune")
.path("/random")
.method("GET")
.willRespondWith()
.headers(headers)
.status(200)
.body(responseBody).toFragment();
}
开发者ID:spring-cloud-services-samples,项目名称:fortune-teller,代码行数:18,代码来源:FortuneServicePactTest.java
示例9: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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();
}
开发者ID:WillemJiang,项目名称:acmeair,代码行数:12,代码来源:UserCommandFetchingCustomerFailedTest.java
示例10: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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();
}
开发者ID:WillemJiang,项目名称:acmeair,代码行数:13,代码来源:RemoteCustomerLoaderTest.java
示例11: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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();
}
开发者ID:WillemJiang,项目名称:acmeair,代码行数:13,代码来源:RemoteCustomerLoaderFailedTest.java
示例12: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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();
}
开发者ID:DiUS,项目名称:pact-workshop-android,代码行数:13,代码来源:ServiceNoContentPactTest.java
示例13: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的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();
}
开发者ID:DiUS,项目名称:pact-workshop-android,代码行数:13,代码来源:ServiceMissingQueryPactTest.java
示例14: createFragment
import au.com.dius.pact.model.PactFragment; //导入依赖的package包/类
@Pact(provider = "Product_Catalogue_Provider", consumer = "Product_Catalogue_Consumer")
public PactFragment createFragment(PactDslWithProvider builder) {
return builder.given("products exist")
.uponReceiving("a request for the product catalogue")
.path("/products")
.method("GET")
.headers(ImmutableMap.of(ACCEPT, HAL_JSON))
.willRespondWith()
.headers(ImmutableMap.of(CONTENT_TYPE, HAL_JSON))
.status(200)
.body(new PactDslJsonBody()
.integerType("page", 1)
.integerType("perPage", 10)
.integerType("totalCount", 1)
.object("_links")
.object("self")
.stringType("href", "/products")
.closeObject()
.closeObject()
.object("_embedded")
.eachLike("items")
.stringType("id", "LRPL")
.stringMatcher("createdOn", "\\d{4}-\\d{1,2}-\\d{1,2}", "2016-2-28")
.stringType("name", "Personal Loan")
.stringType("description", "Low Rate Personal Loan")
.stringType("logo", "/cdn/logos/lrpl.webp")
.object("_links")
.object("self")
.stringType("href", "/products/LRPL")
.stringType("title", "Personal Loan")
.closeObject()
.closeObject()
.closeObject()
.closeArray()
.closeObject())
.toFragment();
}
开发者ID:robcrowley,项目名称:microservices-pact-demo,代码行数:38,代码来源:ProductCatalogueServiceAdapterTests.java
示例15: createFragmentForUploading
import au.com.dius.pact.model.PactFragment; //导入依赖的package包/类
@Pact(state = "no-pacts-present", provider = "broker-maven-plugin", consumer = "pact-broker")
public PactFragment createFragmentForUploading(PactDslWithState builder) {
return builder
.uponReceiving("a pact file")
.path("/pacts/provider/" + PROVIDER_NAME + "/consumer/" + CONSUMER_NAME + "/version/"
+ CONSUMER_VERSION).body(pactJson).headers(getWriteRequestHeaders()).method("PUT").willRespondWith()
.headers(getResponseHeaders()).status(201).body(pactJson)
.toFragment();
}
开发者ID:warmuuh,项目名称:pactbroker-maven-plugin,代码行数:11,代码来源:BrokerRepositoryProviderTest.java
示例16: createFragmentForUploadingAndTagging
import au.com.dius.pact.model.PactFragment; //导入依赖的package包/类
@Pact(state = "no-pacts-present-with-tagging", provider = "broker-maven-plugin", consumer = "pact-broker")
public PactFragment createFragmentForUploadingAndTagging(PactDslWithState builder) {
return builder
.uponReceiving("a pact file")
.path("/pacts/provider/" + PROVIDER_NAME + "/consumer/" + CONSUMER_NAME + "/version/"
+ CONSUMER_VERSION).body(pactJson).headers(getWriteRequestHeaders()).method("PUT").willRespondWith()
.headers(getResponseHeaders()).status(201).body(pactJson)
.uponReceiving("a pact tagging request")
.path("/pacticipants/" + CONSUMER_NAME + "/versions/" + CONSUMER_VERSION + "/tags/" + TAG_NAME.get()).headers(getResponseHeaders()).method("PUT").willRespondWith()
.headers(getResponseHeaders()).status(201)
.toFragment();
}
开发者ID:warmuuh,项目名称:pactbroker-maven-plugin,代码行数:14,代码来源:BrokerRepositoryProviderTest.java
示例17: createFragmentForDownloadingPactLinks
import au.com.dius.pact.model.PactFragment; //导入依赖的package包/类
@Pact(state = "one-provider-pact-link-present", provider = "broker-maven-plugin", consumer = "pact-broker")
public PactFragment createFragmentForDownloadingPactLinks(PactDslWithState builder) {
return builder.uponReceiving("a request for the latest provider pacts")
.path("/pacts/provider/" + PROVIDER_NAME + "/latest").headers(getReadRequestHeaders()).method("GET")
.willRespondWith().headers(getResponseHeaders()).status(200).body(providerJson).toFragment();
}
开发者ID:warmuuh,项目名称:pactbroker-maven-plugin,代码行数:8,代码来源:BrokerRepositoryProviderTest.java
示例18: createFragmentForDownloadingPactLinksForProdTag
import au.com.dius.pact.model.PactFragment; //导入依赖的package包/类
@Pact(state = "one-prod-provider-pact-link-present", provider = "broker-maven-plugin", consumer = "pact-broker")
public PactFragment createFragmentForDownloadingPactLinksForProdTag(PactDslWithState builder) {
return builder.uponReceiving("a request for the latest provider pacts for the prod tag")
.path("/pacts/provider/" + PROVIDER_NAME + "/latest/prod").headers(getReadRequestHeaders()).method("GET")
.willRespondWith().headers(getResponseHeaders()).status(200).body(providerJson).toFragment();
}
开发者ID:warmuuh,项目名称:pactbroker-maven-plugin,代码行数:8,代码来源:BrokerRepositoryProviderTest.java
示例19: createFragmentForUploadingPact
import au.com.dius.pact.model.PactFragment; //导入依赖的package包/类
@Pact(state = "pact-already-uploaded", provider = "broker-maven-plugin", consumer = "pact-broker")
public PactFragment createFragmentForUploadingPact(PactDslWithState builder) {
return builder.uponReceiving("an already existing pact file").path(pactPath).headers(getWriteRequestHeaders())
.method("PUT").willRespondWith().headers(getResponseHeaders()).status(200).body(pactJson).toFragment();
}
开发者ID:warmuuh,项目名称:pactbroker-maven-plugin,代码行数:7,代码来源:BrokerRepositoryProviderTest.java
示例20: createFragmentForDownloadingPact
import au.com.dius.pact.model.PactFragment; //导入依赖的package包/类
@Pact(state = "one-pact-present", provider = "broker-maven-plugin", consumer = "pact-broker")
public PactFragment createFragmentForDownloadingPact(PactDslWithState builder) {
return builder.uponReceiving("a request for the latest provider pacts").path(pactPath).headers(getReadRequestHeaders())
.method("GET").willRespondWith().headers(getResponseHeaders()).status(200).body(pactJson).toFragment();
}
开发者ID:warmuuh,项目名称:pactbroker-maven-plugin,代码行数:7,代码来源:BrokerRepositoryProviderTest.java
注:本文中的au.com.dius.pact.model.PactFragment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论