Skip to content

Instantly share code, notes, and snippets.

@artemptushkin
Last active December 11, 2020 19:13
Show Gist options
  • Save artemptushkin/ad3b610ab9f32984aae750204cce6294 to your computer and use it in GitHub Desktop.
Save artemptushkin/ad3b610ab9f32984aae750204cce6294 to your computer and use it in GitHub Desktop.
The basic setup of pact provider using `au.com.dius.pact.provider:junit`
@RunWith(RestPactRunner.class)
@Provider("billing")
@PactBroker(consumerVersionSelectors = {
@VersionSelector(consumer = "transactions")
})
public class TariffProviderPactTest {
@Autowired
private TariffRepository tariffRepository;
@TestTarget
public final Target target = new HttpTarget("http", "localhost", 8080);
private Long id;
@State(value = "tariff-for-transactions", action = StateChangeAction.SETUP)
public void subscriptionStationState() {
Tariff tariff = new Tariff(1.10, 2.25);
tariffRepository.save(tariff);
id = tariff.getId();
}
@State(value = "tariff-for-transactions", action = StateChangeAction.TEARDOWN)
public void subscriptionStationState() {
tariffRepository.deleteById(id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment