本文整理汇总了Java中au.com.dius.pact.model.RequestResponsePact类的典型用法代码示例。如果您正苦于以下问题:Java RequestResponsePact类的具体用法?Java RequestResponsePact怎么用?Java RequestResponsePact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestResponsePact类属于au.com.dius.pact.model包,在下文中一共展示了RequestResponsePact类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: writePact
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
public void writePact(String url, long requestId, RequestResponsePact pact) {
String filename = outputPath + "/" + url.replaceAll("[^\\p{Alnum}]", "_") + requestId;
try {
String pactDefinition;
try (StringWriter strOut = new StringWriter()) {
PactWriter.writePact(pact, new PrintWriter(strOut));
pactDefinition = strOut.toString();
}
try (PrintWriter out = new PrintWriter(filename)) {
out.println( pactDefinition );
}
LOGGER.debug("Pact file: {}", pactDefinition);
} catch (IOException e) {
rethrowRuntimeException(e);
}
}
开发者ID:ddebree,项目名称:pact-proxy,代码行数:18,代码来源:PactResultWriter.java
示例2: createFragment
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的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
示例3: createFragment
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的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
示例4: resolvePactAnnotation
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
private Optional<Pact> resolvePactAnnotation(Optional<Class<?>> clazz, Method method) {
Pact pactMethodAnnotation = method.getAnnotation(Pact.class);
if (pactMethodAnnotation == null) {
// It can be at class level.
if (clazz.isPresent()) {
return Optional.ofNullable(clazz.get().getAnnotation(Pact.class));
} else {
// method will be ignored.
logger.log(Level.INFO, String.format(
"Method %s returns a %s type but it is not annotated at method nor at class level with %s",
method.getName(),
RequestResponsePact.class.getName(),
Pact.class.getName()));
return null;
}
} else {
return Optional.of(pactMethodAnnotation);
}
}
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:21,代码来源:AbstractConsumerPactTest.java
示例5: run
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
@Override
public Object run() {
long requestId = COUNTER.incrementAndGet();
try {
RequestContext context = RequestContext.getCurrentContext();
HttpServletRequest request = context.getRequest();
String url = request.getRequestURL().toString();
LOGGER.info("Request context: {}", context);
LOGGER.info("Request {}: {} request to {}", requestId, request.getMethod(), url);
PactDslRequestWithPath pactRequest = ConsumerPactBuilder
.consumer(clientName)
.hasPactWith(providerName)
.uponReceiving("Request id " + requestId)
.path(url)
.method(request.getMethod());
buildRequestBody(pactRequest);
PactDslResponse pactResponse = pactRequest
.willRespondWith()
.status(context.getResponseStatusCode());
buildResponseBody(pactResponse);
RequestResponsePact pact = pactResponse.toFragment().toPact();
pactResultWriter.writePact(url, requestId, pact);
} catch (IOException e) {
rethrowRuntimeException(e);
}
return null;
}
开发者ID:ddebree,项目名称:pact-proxy,代码行数:35,代码来源:PactRecorderFilter.java
示例6: test
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
@Test
public void test() {
String resp = rest.getForObject(REQUEST_PATH, String.class);
assertThat(resp).isEqualTo(RESPONSE_BODY);
ArgumentCaptor<RequestResponsePact> argument = ArgumentCaptor.forClass(RequestResponsePact.class);
verify(pactResultWriter).writePact(endsWith("/some-service"), anyLong(), argument.capture());
}
开发者ID:ddebree,项目名称:pact-proxy,代码行数:9,代码来源:PactProxyApplicationTest.java
示例7: create_ec2_instance_when_rds_create_db_instance
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
protected RequestResponsePact create_ec2_instance_when_rds_create_db_instance() {
return ConsumerPactBuilder.consumer("RDS").hasPactWith("EC2")
.uponReceiving("a request to create an ec2 instance")
.headers("Content-Type", "application/json")
.body(requestData)
.method(HttpMethod.POST)
.path("/instances")
.willRespondWith()
.body(responseData)
.toPact();
}
开发者ID:whunmr,项目名称:spring-server,代码行数:12,代码来源:InstancesFacadePactTest.java
示例8: run
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
public static void run(RequestResponsePact pact, PactTestRun pactTestRun) {
MockProviderConfig config = MockProviderConfig.createDefault("localhost", PactSpecVersion.V2);
config.setPort(9002);
PactVerificationResult result = runConsumerTest(pact, config, pactTestRun);
if (result instanceof PactVerificationResult.Error) {
throw new RuntimeException(((PactVerificationResult.Error)result).getError());
}
assertEquals(PactVerificationResult.Ok.INSTANCE, result);
}
开发者ID:whunmr,项目名称:spring-server,代码行数:12,代码来源:PactTest.java
示例9: validatePactSignature
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的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
示例10: findPactFragmentMethods
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
private List<Method> findPactFragmentMethods(TestClass testClass) {
final Method[] methods = testClass.getJavaClass().getMethods();
return Arrays.stream(methods)
.filter(method -> method.getReturnType().isAssignableFrom(RequestResponsePact.class))
.collect(Collectors.toList());
}
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:8,代码来源:AbstractConsumerPactTest.java
示例11: tonyStarkCreditScore
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的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
示例12: hawleyGriffinCreditScore
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
@Pact(provider = CREDIT_SCORE_SERVICE, consumer = SPECIAL_MEMBERSHIP_SERVICE)
public RequestResponsePact hawleyGriffinCreditScore(PactDslWithProvider pact) {
return pact.given("There is not a [email protected]")
.uponReceiving("A credit score request for [email protected]")
.path("/credit-scores/[email protected]").method("GET")
.willRespondWith()
.status(404)
.toPact();
}
开发者ID:andreschaffer,项目名称:microservices-testing-examples,代码行数:10,代码来源:CreditScoreServicePactIT.java
示例13: createPact
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
@Override
protected RequestResponsePact createPact(PactDslWithProvider builder) {
return builder
.uponReceiving("a root request").method("GET").path("/")
.willRespondWith().status(200).body("Hello, world!")
.toPact();
}
开发者ID:mvitz,项目名称:pact-example,代码行数:8,代码来源:ConsumerInheritanceTest.java
示例14: createFragment
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
@Pact(consumer = "My JAX-RS Consumer")
public RequestResponsePact createFragment(PactDslWithProvider builder) {
return builder
.uponReceiving("a root request").method("GET").path("/")
.willRespondWith().status(200).body("Hello, world!")
.toPact();
}
开发者ID:mvitz,项目名称:pact-example,代码行数:8,代码来源:ConsumerAnnotationTest.java
示例15: shouldGetValidatedEidasAuthnResponseFromSamlEngine
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
@Pact(consumer = POLICY_SERVICE, provider = SAML_ENGINE_SERVICE)
public RequestResponsePact shouldGetValidatedEidasAuthnResponseFromSamlEngine(PactDslWithProvider pact) {
return pact
.uponReceiving("A request to validate the Authn Response")
.path(Urls.SamlEngineUrls.TRANSLATE_COUNTRY_AUTHN_RESPONSE_RESOURCE).method("POST")
.headers(singletonMap(CONTENT_TYPE, APPLICATION_JSON))
.body(
new PactDslJsonBody()
.stringValue("samlResponse", samlAuthnResponseContainerDto.getSamlResponse())
.stringValue("principalIPAddressAsSeenByHub", samlAuthnResponseContainerDto.getPrincipalIPAddressAsSeenByHub())
.stringValue("matchingServiceEntityId", TEST_RP_MS)
.object("sessionId")
.stringValue("sessionId", sessionId.getSessionId())
.closeObject()
)
.willRespondWith()
.status(Response.Status.OK.getStatusCode())
.headers(singletonMap(CONTENT_TYPE, APPLICATION_JSON))
.body(
new PactDslJsonBody()
.stringValue("issuer", COUNTRY_ENTITY_ID)
.stringValue("persistentId", "UK/GB/12345")
.stringValue("status", "Success")
.nullValue("statusMessage")
.stringMatcher("encryptedIdentityAssertionBlob", ".+", encryptedIdentityAssertionString)
.stringValue("levelOfAssurance", "LEVEL_2")
)
.uponReceiving("A request to generate an attribute query request")
.path(Urls.SamlEngineUrls.GENERATE_COUNTRY_ATTRIBUTE_QUERY_RESOURCE).method("POST")
.headers(singletonMap(CONTENT_TYPE, APPLICATION_JSON))
.body(
new PactDslJsonBody()
.stringMatcher("requestId", ".+", ID)
.stringValue("assertionConsumerServiceUri", "/default-service-index")
.stringValue("encryptedIdentityAssertion", encryptedIdentityAssertionString)
.stringValue("authnRequestIssuerEntityId", TEST_RP)
.stringValue("levelOfAssurance", "LEVEL_2")
.stringValue("matchingServiceAdapterUri", MATCHING_SERVICE_URI)
.stringValue("matchingServiceEntityId", TEST_RP_MS)
.timestamp("matchingServiceRequestTimeOut", "yyyy-MM-dd'T'HH:mm:ss.S'Z'")
.booleanValue("onboarding", true)
.nullValue("cycle3Dataset")
.nullValue("userAccountCreationAttributes")
.timestamp("assertionExpiry", "yyyy-MM-dd'T'HH:mm:ss.S'Z'")
.object("persistentId")
.stringValue("nameId", "UK/GB/12345")
.closeObject()
)
.willRespondWith()
.status(Response.Status.OK.getStatusCode())
.headers(singletonMap(CONTENT_TYPE, APPLICATION_JSON))
.body(
new PactDslJsonBody()
.stringMatcher("samlRequest", "[\\s\\S]+", SAML_ATTRIBUTE_QUERY)
.stringValue("matchingServiceUri", MATCHING_SERVICE_URI)
.stringValue("id", ID)
.stringValue("issuer", EIDAS_HUB_ENTITY_ID)
.timestamp("attributeQueryClientTimeOut", "yyyy-MM-dd'T'HH:mm:ss.S'Z'")
.booleanValue("onboarding", true)
)
.toPact();
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:64,代码来源:EidasSessionResourceContractTest.java
示例16: runPactTest
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
private PactVerificationResult runPactTest(EventContext<Test> base, RequestResponsePact requestResponsePact) {
return runConsumerTest(requestResponsePact, mockProviderConfigInstance.get(), mockServer -> base.proceed());
}
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:4,代码来源:AbstractConsumerPactTest.java
示例17: contract1
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
@Pact(consumer = "c1", provider = "p1")
public RequestResponsePact contract1(PactDslWithProvider builder) {
return null;
}
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:5,代码来源:ConsumerPactTestTest.java
示例18: contract2
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
public RequestResponsePact contract2(PactDslWithProvider builder) {
return null;
}
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:4,代码来源:ConsumerPactTestTest.java
示例19: contract3
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
@Pact(consumer = "c4", provider = "p4")
public RequestResponsePact contract3(PactDslWithProvider builder) {
return null;
}
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:5,代码来源:ConsumerPactTestTest.java
示例20: executePacts
import au.com.dius.pact.model.RequestResponsePact; //导入依赖的package包/类
private void executePacts(EventContext<Test> test, final Pacts pacts, final Field interactionField,
final Field consumerField) {
final TestClass testClass = test.getEvent().getTestClass();
final Object testInstance = test.getEvent().getTestInstance();
for (Pact pact : pacts.getPacts()) {
RequestResponsePact requestResponsePact = (RequestResponsePact) pact;
// Inject current consumer
if (consumerField != null) {
setField(testInstance, consumerField, pact.getConsumer());
}
for (final RequestResponseInteraction interaction : requestResponsePact.getInteractions()) {
executeStateChanges(interaction, testClass, testInstance);
Target target = targetInstance.get();
if (target instanceof ArquillianTestClassAwareTarget) {
ArquillianTestClassAwareTarget arquillianTestClassAwareTarget =
(ArquillianTestClassAwareTarget) target;
arquillianTestClassAwareTarget.setTestClass(testClass, testInstance);
}
if (target instanceof PactProviderExecutionAwareTarget) {
PactProviderExecutionAwareTarget pactProviderExecutionAwareTarget =
(PactProviderExecutionAwareTarget) target;
pactProviderExecutionAwareTarget.setConsumer(pact.getConsumer());
pactProviderExecutionAwareTarget.setRequestResponseInteraction(interaction);
}
// Inject current interaction to test
if (interactionField != null) {
setField(testInstance, interactionField, interaction);
}
// run the test
test.proceed();
}
}
}
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:42,代码来源:InteractionRunner.java
注:本文中的au.com.dius.pact.model.RequestResponsePact类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论