@Override public void testInteraction() { if (this.currentConsumer == null || this.currentRequestResponseInteraction == null) { throw new IllegalArgumentException("Current Consumer or Current Request Response Interaction has not been set."); } try { testInteraction(this.currentConsumer.getName(), this.currentRequestResponseInteraction); } finally { // Each run should provide a new pair of objects. resetCurrentFields(); } }
/** * Creates a new instance of {@link MessagePactBuilder} * * @param consumer */ private MessagePactBuilder(String consumer) { this.consumer = new Consumer(consumer); }
@Override public void testInteraction(URL url) { if (this.currentConsumer == null || this.currentRequestResponseInteraction == null) { throw new IllegalArgumentException("Current Consumer or Current Request Response Interaction has not been set."); } try { testInteraction(url, this.currentConsumer.getName(), this.currentRequestResponseInteraction); } finally { // Each run should provide a new pair of objects. resetCurrentFields(); } }
/** * Creates a new instance of {@link MessagePactBuilder} * * @param consumer */ private MessagePactBuilder(String consumer) { this.consumer = new Consumer(consumer); }
@Override public void testInteraction(URL url) { if (this.currentConsumer == null || this.currentRequestResponseInteraction == null) { throw new IllegalArgumentException( "Current Consumer or Current Request Response Interaction has not been set."); } try { testInteraction(url, this.currentConsumer.getName(), this.currentRequestResponseInteraction); } finally { // Each run should provide a new pair of objects. resetCurrentFields(); } }
this.consumer = new Consumer(consumerName); this.provider = new Provider(providerName);
@Override public void testInteraction() { if (this.currentConsumer == null || this.currentRequestResponseInteraction == null) { throw new IllegalArgumentException( "Current Consumer or Current Request Response Interaction has not been set."); } try { testInteraction(this.currentConsumer.getName(), this.currentRequestResponseInteraction); } finally { // Each run should provide a new pair of objects. resetCurrentFields(); } }
this.consumer = new Consumer(consumerName); this.provider = new Provider(providerName);
protected Description describeChild(final Interaction interaction) { if (!childDescriptions.containsKey(interaction)) { childDescriptions.put(interaction, Description.createTestDescription(testClass.getJavaClass(), pact.getConsumer().getName() + " - " + interaction.getDescription())); } return childDescriptions.get(interaction); }
protected List<Pact> getPacts(BeforeClass test) { final TestClass testClass = test.getTestClass(); final Provider providerInfo = testClass.getAnnotation(Provider.class); if (providerInfo == null) { throw new IllegalArgumentException(String.format("Provider name should be set by using %s",Provider.class.getName())); } final String serviceName = providerInfo.value(); final Consumer consumerInfo = testClass.getAnnotation(Consumer.class); final String consumerName = consumerInfo != null ? consumerInfo.value() : null; List<Pact> pacts = new ArrayList<>(); try { pacts = getPactSource(testClass).load(serviceName).stream() .filter(p -> consumerName == null || p.getConsumer().getName().equals(consumerName)) .collect(toList()); } catch (IOException e) { throw new IllegalArgumentException(e); } return pacts; }
protected List<Pact> getPacts(BeforeClass test) { final TestClass testClass = test.getTestClass(); final Provider providerInfo = testClass.getAnnotation(Provider.class); if (providerInfo == null) { throw new IllegalArgumentException( String.format("Provider name should be set by using %s", Provider.class.getName())); } final String serviceName = providerInfo.value(); final Consumer consumerInfo = testClass.getAnnotation(Consumer.class); final String consumerName = consumerInfo != null ? consumerInfo.value() : null; List<Pact> pacts = new ArrayList<>(); try { final ContractsRetriever contractsSource = getContractsSource(testClass, algeronProviderConfigurationInstance.get()); contractsSource.setProviderName(serviceName); final List<URI> contractsDirectory = contractsSource.retrieve(); pacts = loadContractFiles(contractsDirectory, serviceName).stream() .filter(p -> consumerName == null || p.getConsumer().getName().equals(consumerName)) .collect(toList()); } catch (IOException e) { throw new IllegalArgumentException(e); } return pacts; }
@Override public void evaluate() throws Throwable { setupTargetForInteraction(target); target.addResultCallback((result, verifier) -> results.put(interaction, new Pair<>(result, verifier))); surrogateTestMethod(); target.testInteraction(pact.getConsumer().getName(), interaction, source); } };
/** * Adds a provider state to this interaction * @param state Description of the state * @param params Data parameters for this state */ public PactDslWithState given(String state, Map<String, Object> params) { addInteraction(); return new PactDslWithState(consumerPactBuilder, request.consumer.getName(), request.provider.getName(), new ProviderState(state, params), defaultRequestValues, defaultResponseValues); } }
/** * Adds a provider state to this interaction * @param state Description of the state */ public PactDslWithState given(String state) { addInteraction(); return new PactDslWithState(consumerPactBuilder, request.consumer.getName(), request.provider.getName(), new ProviderState(state), defaultRequestValues, defaultResponseValues); }
/** * Adds a provider state to this interaction * @param state Description of the state */ public PactDslWithState given(String state) { addInteraction(); return new PactDslWithState(consumerPactBuilder, request.consumer.getName(), request.provider.getName(), new ProviderState(state), defaultRequestValues, defaultResponseValues); }
/** * Adds a provider state to this interaction * @param state Description of the state * @param params Data parameters for this state */ public PactDslWithState given(String state, Map<String, Object> params) { addInteraction(); return new PactDslWithState(consumerPactBuilder, request.consumer.getName(), request.provider.getName(), new ProviderState(state, params), defaultRequestValues, defaultResponseValues); }