• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PactDslWithProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中au.com.dius.pact.consumer.dsl.PactDslWithProvider的典型用法代码示例。如果您正苦于以下问题:Java PactDslWithProvider类的具体用法?Java PactDslWithProvider怎么用?Java PactDslWithProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PactDslWithProvider类属于au.com.dius.pact.consumer.dsl包,在下文中一共展示了PactDslWithProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
 
开发者ID:azusa,项目名称:pact-jvm-example,代码行数:23,代码来源:AnimalServiceClient.java


示例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();
}
 
开发者ID:WillemJiang,项目名称:acmeair,代码行数:17,代码来源:AuthenticationCommandValidationFailedTest.java


示例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();
}
 
开发者ID:DiUS,项目名称:pact-workshop-android,代码行数:25,代码来源:ServicePactTest.java


示例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();
}
 
开发者ID:WillemJiang,项目名称:acmeair,代码行数:18,代码来源:AuthenticationCommandValidationTest.java


示例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();
}
 
开发者ID:WillemJiang,项目名称:acmeair,代码行数:17,代码来源:UserCommandTest.java


示例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();
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:18,代码来源:ConsumerTest.java


示例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();
    }
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:17,代码来源:ClientGatewayTest.java


示例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();
}
 
开发者ID:WillemJiang,项目名称:acmeair,代码行数:12,代码来源:UserCommandFetchingCustomerFailedTest.java


示例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();
}
 
开发者ID:WillemJiang,项目名称:acmeair,代码行数:13,代码来源:RemoteCustomerLoaderTest.java


示例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();
}
 
开发者ID:WillemJiang,项目名称:acmeair,代码行数:13,代码来源:RemoteCustomerLoaderFailedTest.java


示例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();
}
 
开发者ID:DiUS,项目名称:pact-workshop-android,代码行数:13,代码来源:ServiceNoContentPactTest.java


示例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();
}
 
开发者ID:DiUS,项目名称:pact-workshop-android,代码行数:13,代码来源:ServiceMissingQueryPactTest.java


示例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)'");
    }
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:12,代码来源:AbstractConsumerPactTest.java


示例16: should_get_pact_from_method

import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Test
public void should_get_pact_from_method() throws NoSuchMethodException {

    AbstractConsumerPactTest abstractConsumerPactTest = new StandaloneConsumerPactTest();
    TestClass testClass = new TestClass(PactMethod.class);
    final Optional<AbstractConsumerPactTest.PactMethod> pactFragmentMethod =
        abstractConsumerPactTest.findPactMethod("p1", testClass, pactVerification);

    final Method annotatedMethod = PactMethod.class.getMethod("contract1", PactDslWithProvider.class);
    assertThat(pactFragmentMethod.get().getMethod())
        .isEqualTo(annotatedMethod);
    assertThat(pactFragmentMethod.get().getPact())
        .isEqualTo(annotatedMethod.getAnnotation(Pact.class));
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:15,代码来源:ConsumerPactTestTest.java


示例17: should_get_pact_from_class

import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Test
public void should_get_pact_from_class() throws NoSuchMethodException {

    AbstractConsumerPactTest abstractConsumerPactTest = new StandaloneConsumerPactTest();
    TestClass testClass = new TestClass(PactClass.class);

    final Optional<AbstractConsumerPactTest.PactMethod> pactFragmentMethod =
        abstractConsumerPactTest.findPactMethod("p2", testClass, pactVerification);

    assertThat(pactFragmentMethod.get().getMethod())
        .isEqualTo(PactClass.class.getMethod("contract2", PactDslWithProvider.class));
    assertThat(pactFragmentMethod.get().getPact())
        .isEqualTo(PactClass.class.getAnnotation(Pact.class));
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:15,代码来源:ConsumerPactTestTest.java


示例18: should_give_preference_to_method_annotation

import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Test
public void should_give_preference_to_method_annotation() throws NoSuchMethodException {

    AbstractConsumerPactTest abstractConsumerPactTest = new StandaloneConsumerPactTest();
    TestClass testClass = new TestClass(PactMethodClass.class);

    final Optional<AbstractConsumerPactTest.PactMethod> pactFragmentMethod =
        abstractConsumerPactTest.findPactMethod("p4", testClass, pactVerification);

    final Method annotatedMethod = PactMethodClass.class.getMethod("contract3", PactDslWithProvider.class);
    assertThat(pactFragmentMethod.get().getMethod())
        .isEqualTo(annotatedMethod);
    assertThat(pactFragmentMethod.get().getPact())
        .isEqualTo(annotatedMethod.getAnnotation(Pact.class));
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:16,代码来源:ConsumerPactTestTest.java


示例19: createFragment

import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的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


示例20: tonyStarkCreditScore

import au.com.dius.pact.consumer.dsl.PactDslWithProvider; //导入依赖的package包/类
@Pact(provider = CREDIT_SCORE_SERVICE, consumer = SPECIAL_MEMBERSHIP_SERVICE)
public RequestResponsePact tonyStarkCreditScore(PactDslWithProvider pact) {
    return pact.given("There is a [email protected]")
            .uponReceiving("A credit score request for [email protected]")
            .path("/credit-scores/[email protected]").method("GET")
            .willRespondWith()
            .status(200)
            .body(new PactDslJsonBody().integerType("creditScore", 850))
            .headers(singletonMap(CONTENT_TYPE, APPLICATION_JSON))
            .toPact();
}
 
开发者ID:andreschaffer,项目名称:microservices-testing-examples,代码行数:12,代码来源:CreditScoreServicePactIT.java



注:本文中的au.com.dius.pact.consumer.dsl.PactDslWithProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java QuorumStats类代码示例发布时间:2022-05-22
下一篇:
Java SnmpUsmKeyHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap