{"id":385217,"date":"2024-06-29T05:58:50","date_gmt":"2024-06-29T05:58:50","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=385217"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=385217","title":{"rendered":"<span>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u2014 \u0447\u0430\u0441\u0442\u044c 2<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e01\/b5b\/41c\/e01b5b41c7cde9f1ae41e9dbfb2927a9.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e01\/b5b\/41c\/e01b5b41c7cde9f1ae41e9dbfb2927a9.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 <a href=\"https:\/\/swapnilsankla.me\/post\/consumer-driven-contract-tests-part-1\"><u>\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c<\/u><\/a> \u0431\u043b\u043e\u0433\u0435 \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0447\u0435\u0440\u0435\u0437 Http. \u041e\u043d\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>Pact-jvm<\/p>\n<\/li>\n<li>\n<p>Junit5<\/p>\n<\/li>\n<li>\n<p>Gradle<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/SwapnilSankla\/cdc.git\"><u>github<\/u><\/a>.<\/p>\n<p>\u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c\u0438. \u041e\u043d\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0438\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0435\u043d\u044b. \u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f \u043d\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u044e\u0442\u0441\u044f. Pact \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p><strong>\u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0442\u0435\u0441\u0442<\/strong><\/p>\n<p>\u0422\u0435\u0441\u0442\u044b \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430. \u0426\u0435\u043b\u044c \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 &#8212; \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0432\u044b\u0434\u0430\u0447\u0438 \u043a\u0440\u0435\u0434\u0438\u0442\u043e\u0432 \u0438 \u0441\u043b\u0443\u0436\u0431\u044b \u043f\u043e \u0431\u043e\u0440\u044c\u0431\u0435 \u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c. \u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u043f\u043e\u0440\u0442\u0430\u043b \u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e \u0431\u043e\u0440\u044c\u0431\u0435 \u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c &#8212; \u044d\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u0432 <a href=\"https:\/\/swapnilsankla.me\/post\/consumer-driven-contract-tests-part-1\"><u>\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c<\/u><\/a> \u0431\u043b\u043e\u0433\u0435. \u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0448\u043b\u044e\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432 \u0441\u043b\u0443\u0436\u0431\u0443 \u043f\u043e \u0431\u043e\u0440\u044c\u0431\u0435 \u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u0438\u043c\u0435\u0435\u0442 \u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u043a\u0430 \u0438\u043b\u0438 \u043d\u0435\u0442. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 <code>FraudCheckService<\/code> \u0432 \u0441\u043b\u0443\u0436\u0431\u0435 \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u043e\u0433\u043e \u0448\u043b\u044e\u0437\u0430.<\/p>\n<pre><code class=\"kotlin\">@Service class FraudCheckService(    @Value(\"\\${loan-gateway.fraud-service-url}\")    private val fraudProviderUrl: String,    private val restTemplate: RestTemplate,    private val eventPublisher: ApplicationEventPublisher ) {    fun isFraudulent(customerId: String): FraudCheck {        val fraudCheck = try {            val responseBody = restTemplate.getForEntity(                fraudProviderUrl.replace(\"{customerId}\", customerId),                FraudCheck::class.java            ).body            FraudCheck(responseBody?.status ?: true)        } catch (e: HttpClientErrorException) {            FraudCheck(true)        }        publishEvent(customerId, fraudCheck)        return fraudCheck    }    private fun publishEvent(customerId: String, fraudCheck: FraudCheck) {        val loanApplicationEvent = LoanApplicationEvent(LoanApplication(customerId, fraudCheck))        eventPublisher.publishEvent(loanApplicationEvent)    } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>1.\u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0435\u0441\u0442 spring boot, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 id &#171;1&#187; \u0441\u0442\u0430\u0442\u0443\u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0436\u043d\u044b\u043c.<\/p>\n<pre><code class=\"kotlin\">@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) class FraudCheckServiceConsumerTest {     @Autowired    private lateinit var fraudCheckService: FraudCheckService     @Test    fun `should return fraud details with status as false for customerId 1`() {        fraudCheckService.isFraudulent(\"1\").status shouldBe false    } }<\/code><\/pre>\n<p>2. \u042d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0430\u043b\u0435\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0441\u043b\u0443\u0436\u0431\u044b \u043f\u043e \u0431\u043e\u0440\u044c\u0431\u0435 \u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c. \u0422\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u043d \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u043b\u0443\u0436\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e.<\/p>\n<pre><code class=\"kotlin\">@Test fun `should return fraud details with status as false for customerId 1`() {    val mockResponse = MockResponse()        .setBody(\"\"\"{ \"status\": false }\"\"\")        .addHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE)    mockWebServer.enqueue(mockResponse)        fraudCheckService.isFraudulent(\"1\").status shouldBe false } \/\/ Using okhttp3.mockwebserver.MockWebServer<\/code><\/pre>\n<p>3. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442.<\/p>\n<pre><code class=\"kotlin\">@Pact(provider = \"fraud_service\", consumer = \"loan_gateway\") fun nonFraudulentCustomer(pactDsl: PactDslWithProvider): RequestResponsePact {    return pactDsl        .given(\"Customer with id 1 is setup to return false fraudulent status\")        .uponReceiving(\"When fraud status is requested for nonFraudulent customer\")        .method(\"GET\")        .path(\"\/fraud\/1\")        .willRespondWith()        .status(200)        .body(JSONObject(\"\"\"{ \"status\": false }\"\"\"))        .toPact() }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043e\u0442\u0432\u0435\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u043c \u044d\u0442\u043e \u043f\u043e \u043f\u043e\u043b\u043e\u0447\u043a\u0430\u043c.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>@Pact<\/code>(provider = &#171;fraud_service&#187;, consumer = &#171;loan_gateway&#187;)<\/p>\n<\/td>\n<td>\n<p>\u0418\u043c\u0435\u043d\u0430 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u043c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>given<\/code>(&#171;Customer with id 1 is setup to return false fraudulent status&#187;)<\/p>\n<\/td>\n<td>\n<p>\u0414\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043e\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0432 \u0442\u0435\u0441\u0442\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>uponReceiving<\/code>(&#171;When fraud status is requested for nonFraudulent customer&#187;)<\/p>\n<\/td>\n<td>\n<p>\u042d\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u043d\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>method<\/code>(&#171;GET&#187;)<\/p>\n<\/td>\n<td>\n<p>Http-\u043c\u0435\u0442\u043e\u0434<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>path<\/code>(&#171;\/fraud\/1&#187;)<\/p>\n<\/td>\n<td>\n<p>Uri-\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>status<\/code>(200)<\/p>\n<\/td>\n<td>\n<p>\u041a\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>body<\/code>(JSONObject(&#171;&#187;&#187;{ &#171;status&#187;: false }&#187;&#187;&#187;))<\/p>\n<\/td>\n<td>\n<p>\u0422\u0435\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>4. \u0421\u043d\u0430\u0431\u0434\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>PactTestFor<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0442\u0435\u0441\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a \u043c\u0435\u0442\u043e\u0434\u0443 <code>pact<\/code>.<\/p>\n<p>5. \u0421\u043d\u0430\u0431\u0434\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u0442\u0435\u0441\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>PactTestFor<\/code>. \u0420\u0430\u0441\u0448\u0438\u0440\u044c\u0442\u0435 \u0442\u0435\u0441\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 <code>PactConsumerTestExt<\/code>.<\/p>\n<p>6. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0442\u0435\u0441\u0442, \u043e\u043d \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c\u00a0 <code>java.net.BindException: Address already in use<\/code>. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e Pact \u0441\u0430\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u043c \u0438\u043c\u0438\u0442\u0430\u0442\u043e\u0440 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0422\u0435\u0441\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"kotlin\">@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @ExtendWith(PactConsumerTestExt::class) @PactTestFor(port = \"1234\") class FraudCheckServiceConsumerTest {     @Autowired    private lateinit var fraudCheckService: FraudCheckService     @Pact(provider = \"fraud_service\", consumer = \"loan_gateway\")    fun nonFraudulentCustomer(pactDsl: PactDslWithProvider): RequestResponsePact {        return pactDsl            .given(\"Customer with id 1 is setup to return false fraudulent status\")            .uponReceiving(\"When fraud status is requested for nonFraudulent customer\")            .method(\"GET\")            .path(\"\/fraud\/1\")            .willRespondWith()            .status(200)            .body(JSONObject(\"\"\"{ \"status\": false }\"\"\"))            .toPact()    }     @Test    @PactTestFor(pactMethod = \"nonFraudulentCustomer\")    fun `should return fraud details with status as false for customerId 1`() {        fraudCheckService.isFraudulent(\"1\").status shouldBe false    } }<\/code><\/pre>\n<p>7. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0442\u0435\u0441\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0431\u043e\u0447\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 \/target\/pacts.<\/p>\n<pre><code class=\"kotlin\">{  \"provider\": {    \"name\": \"fraud_service\"  },  \"consumer\": {    \"name\": \"loan_gateway\"  },  \"interactions\": [    {      \"description\": \"When fraud status is requested for nonFraudulent customer\",      \"request\": {        \"method\": \"GET\",        \"path\": \"\/fraud\/1\"      },      \"response\": {        \"status\": 200,        \"headers\": {          \"Content-Type\": \"application\/json; charset=UTF-8\"        },        \"body\": {          \"status\": false        },        \"matchingRules\": {          \"header\": {            \"Content-Type\": {              \"matchers\": [                {                  \"match\": \"regex\",                  \"regex\": \"application\/json(;\\\\s?charset=[\\\\w\\\\-]+)?\"                }              ],              \"combine\": \"AND\"            }          }        }      },      \"providerStates\": [        {          \"name\": \"Customer with id 1 is setup to return false fraudulent status\"        }      ]    }  ],  \"metadata\": {    \"pactSpecification\": {      \"version\": \"3.0.0\"    },    \"pact-jvm\": {      \"version\": \"4.0.10\"    }  } }<\/code><\/pre>\n<p>8. \u042d\u0442\u043e\u0442 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443, \u0438 \u043e\u043d \u0443\u0431\u0435\u0436\u0434\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0431\u043c\u0435\u043d\u0430 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c\u0438 pact \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0440\u043e\u043a\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u043c\u0443 \u0431\u0440\u043e\u043a\u0435\u0440\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p><strong>\u0422\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430<\/strong><\/p>\n<p>\u0422\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u0440\u043e\u0432\u043d\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0430\u0431\u043e\u0432\/\u043c\u043e\u043a\u043e\u0432. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0443\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430.<\/p>\n<ol>\n<li>\n<p>\u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0435\u0441\u0442 spring boot \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0441\u043b\u0443\u0436\u0431\u044b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <code>FraudServiceController<\/code>. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">@ActiveProfiles(\"test\") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Import(FraudControllerProviderTest.TestConfiguration::class) class FraudControllerProviderTest {    @org.springframework.boot.test.context.TestConfiguration    class TestConfiguration {        @Bean        fun fraudService(): FraudService {            return mockk() {                every { fraudStatus(\"1\") } returns FraudCheck(false)            }        }    } }<\/code><\/pre>\n<p>2. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0442\u0435\u0441\u0442 spring boot \u0432 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441 \u0445\u043e\u0441\u0442\u043e\u043c \u0438 \u043f\u043e\u0440\u0442\u043e\u043c. \u0418 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<\/p>\n<pre><code class=\"kotlin\">@LocalServerPort private val port = 0  @BeforeEach fun before(context: PactVerificationContext) {    context.target = HttpTestTarget(\"localhost\", port) }  @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) {    context.verifyInteraction() }<\/code><\/pre>\n<p>3. \u0421\u0435\u0439\u0447\u0430\u0441 <code>pact<\/code> \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u044d\u0442\u0438\u0445 pact-\u0444\u0430\u0439\u043b\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439.<\/p>\n<pre><code class=\"kotlin\">@PactFolder(\"target\/pacts\") @Provider(\"fraud_service\")<\/code><\/pre>\n<p>4. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0442\u0435\u0441\u0442. \u0422\u0435\u0441\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c <code>au.com.dius.pact.provider.junit.MissingStateChangeMethod: \u041d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d \u043c\u0435\u0442\u043e\u0434 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 @State<\/code><em>(&#171;Customer with id 1 is setup to return false fraudulent status&#187;)<\/em>.<\/p>\n<p>5. \u0412\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <code>state<\/code>, \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b\u0438 \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435 \u0432 \u043f\u0443\u043d\u043a\u0442\u0435 <code>given<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u0435\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041e\u043d\u0430 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443. \u042d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0443\u0437\u043b\u0435 <code>providerStates<\/code> json \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430.<\/p>\n<p>6. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u0445\u043e\u0442\u044f \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u043e\u043d \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0443\u0436\u0435 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u043b\u0441\u044f \u043c\u043e\u043a. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435, \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0435\u0433\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435.<\/p>\n<pre><code class=\"kotlin\">@State(    value =    [        \"Customer with id 1 is setup to return false fraudulent status\"    ] ) fun setupIfAny() {    \/\/ Nothing to setup as it is taken care by the mock FraudService }<\/code><\/pre>\n<p>7.\u0412\u0435\u0441\u044c \u0442\u0435\u0441\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"kotlin\">@ActiveProfiles(\"test\") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Import(FraudControllerProviderTest.TestConfiguration::class) @PactFolder(\"target\/pacts\") @Provider(\"fraud_service\") class FraudControllerProviderTest {    @LocalServerPort    private val port = 0    @BeforeEach    fun before(context: PactVerificationContext) {        context.target = HttpTestTarget(\"localhost\", port)    }     @TestTemplate    @ExtendWith(PactVerificationInvocationContextProvider::class)    fun pactVerificationTestTemplate(context: PactVerificationContext) {        context.verifyInteraction()    }     @State(        value =        [            \"Customer with id 1 is setup to return false fraudulent status\"        ]    )    fun setupIfAny() {        \/\/ Nothing to setup as it is taken care by the mock FraudService    }     @org.springframework.boot.test.context.TestConfiguration    class TestConfiguration {        @Bean        fun fraudService(): FraudService {            return mockk {                every { fraudStatus(\"1\") } returns FraudCheck(false)            }        }    } }<\/code><\/pre>\n<p>8.\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0442\u0435\u0441\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0438 \u0432\u044b\u0434\u0430\u0441\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0432\u044b\u0432\u043e\u0434\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0435 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u044b, \u0445\u043e\u0442\u044f \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u043d.<\/p>\n<pre><code class=\"kotlin\">Verifying a pact between loan_gateway and fraud_service   [Using Directory target\/pacts]   Given Customer with id 1 is setup to return false fraudulent status   When fraud status is requested for nonFraudulent customer   ...     returns a response which       has status code 200 (OK)       has a matching body (OK) ... Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true') <\/code><\/pre>\n<p><strong>\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/strong><\/p>\n<ol>\n<li>\n<p><code>Pact<\/code> \u0438\u0449\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u00a0 <code>pact.verifier.publishResults<\/code>, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>true<\/code>, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0443\u043a <code>BeforeAllCallback<\/code>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0445\u044d\u043d\u0434\u043b \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"java\">class PactVerificationResultExtension: BeforeAllCallback {    override fun beforeAll(context: ExtensionContext?) {        System.setProperty(\"pact.verifier.publishResults\", \"true\")        System.setProperty(\"pact.provider.version\", \"0.0.3\")    } }<\/code><\/pre>\n<p>4. \u0420\u0430\u0441\u0448\u0438\u0440\u044c\u0442\u0435 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>PactVerificationResultExtension<\/code>, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435<\/p>\n<pre><code class=\"java\">@ExtendWith(PactVerificationResultExtension::class)<\/code><\/pre>\n<p>5. \u0412\u043e\u0442 \u0438 \u0432\u0441\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u044b.<\/p>\n<p>6. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0448\u0430\u0433 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0432 <code>build.gradle<\/code>.<\/p>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 build.gradle<\/strong><\/p>\n<p>1.\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0435\u0439 Gradle <code>ProcessResources<\/code>. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c <code>gradle<\/code> \u0432 \u0444\u0430\u0439\u043b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434 \u0432 <code>build.gradle<\/code>.<\/p>\n<pre><code>processResources {    expand(project.properties) }<\/code><\/pre>\n<p>2. \u0423\u043a\u0430\u0436\u0438\u0442\u0435 \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 application.yaml, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435.<\/p>\n<pre><code class=\"java\">app.version: ${version}<\/code><\/pre>\n<p>3.\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a app.version \u0432 \u0444\u0430\u0439\u043b\u0435 <code>PactVerificationResultExtension<\/code> \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e \u043d\u0430 <code>pact.provider.version<\/code><\/p>\n<pre><code class=\"kotlin\">class PactVerificationResultExtension: BeforeAllCallback {    override fun beforeAll(context: ExtensionContext?) {        System.setProperty(\"pact.verifier.publishResults\", \"true\")        System.setProperty(\"pact.provider.version\", getVersion())    }     private fun getVersion(): String {        return PropertiesLoaderUtils.loadAllProperties(\"application.yaml\")            .getProperty(\"app.version\")    } }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0430 \u0432\u0441\u0435. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0431\u043b\u043e\u0433\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e.<\/p>\n<hr\/>\n<blockquote>\n<p>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/otus.pw\/p8h9\/\">\u00ab\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 Spring Framework\u00bb.<\/a> <\/p>\n<p><em>\u0412\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043d\u0430 \u0434\u0432\u0443\u0445\u0434\u043d\u0435\u0432\u043d\u044b\u0439 \u043e\u043d\u043b\u0430\u0439\u043d-\u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432 <\/em><strong><em>\u00ab\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0411\u0414 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring\u00bb<\/em><\/strong><em>. \u041d\u0430 \u0437\u0430\u043d\u044f\u0442\u0438\u044f\u0445 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0411\u0414 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439: JDBC, JPA + Hiberante. \u0422\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a\u0443\u044e \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0432 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b Spring: Spring JDBC, Spring ORM, Spring Data JPA \u0438 Spring Data JDBC.<\/em><\/p>\n<p><a href=\"https:\/\/otus.pw\/SDQp\/\"><strong>\u2192 \u0420\u0415\u0413\u0418\u0421\u0422\u0420\u0410\u0426\u0418\u042f<\/strong><\/a><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/573174\/\"> https:\/\/habr.com\/ru\/articles\/573174\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 <a href=\"https:\/\/swapnilsankla.me\/post\/consumer-driven-contract-tests-part-1\"><u>\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c<\/u><\/a> \u0431\u043b\u043e\u0433\u0435 \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0447\u0435\u0440\u0435\u0437 Http. \u041e\u043d\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>Pact-jvm<\/p>\n<\/li>\n<li>\n<p>Junit5<\/p>\n<\/li>\n<li>\n<p>Gradle<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/SwapnilSankla\/cdc.git\"><u>github<\/u><\/a>.<\/p>\n<p>\u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c\u0438. \u041e\u043d\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0438\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0435\u043d\u044b. \u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f \u043d\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u044e\u0442\u0441\u044f. Pact \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p><strong>\u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0442\u0435\u0441\u0442<\/strong><\/p>\n<p>\u0422\u0435\u0441\u0442\u044b \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430. \u0426\u0435\u043b\u044c \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 &#8212; \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0432\u044b\u0434\u0430\u0447\u0438 \u043a\u0440\u0435\u0434\u0438\u0442\u043e\u0432 \u0438 \u0441\u043b\u0443\u0436\u0431\u044b \u043f\u043e \u0431\u043e\u0440\u044c\u0431\u0435 \u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c. \u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u043f\u043e\u0440\u0442\u0430\u043b \u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e \u0431\u043e\u0440\u044c\u0431\u0435 \u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c &#8212; \u044d\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u0432 <a href=\"https:\/\/swapnilsankla.me\/post\/consumer-driven-contract-tests-part-1\"><u>\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c<\/u><\/a> \u0431\u043b\u043e\u0433\u0435. \u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0448\u043b\u044e\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432 \u0441\u043b\u0443\u0436\u0431\u0443 \u043f\u043e \u0431\u043e\u0440\u044c\u0431\u0435 \u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u0438\u043c\u0435\u0435\u0442 \u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u043a\u0430 \u0438\u043b\u0438 \u043d\u0435\u0442. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 <code>FraudCheckService<\/code> \u0432 \u0441\u043b\u0443\u0436\u0431\u0435 \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u043e\u0433\u043e \u0448\u043b\u044e\u0437\u0430.<\/p>\n<pre><code class=\"kotlin\">@Service class FraudCheckService(    @Value(\"\\${loan-gateway.fraud-service-url}\")    private val fraudProviderUrl: String,    private val restTemplate: RestTemplate,    private val eventPublisher: ApplicationEventPublisher ) {    fun isFraudulent(customerId: String): FraudCheck {        val fraudCheck = try {            val responseBody = restTemplate.getForEntity(                fraudProviderUrl.replace(\"{customerId}\", customerId),                FraudCheck::class.java            ).body            FraudCheck(responseBody?.status ?: true)        } catch (e: HttpClientErrorException) {            FraudCheck(true)        }        publishEvent(customerId, fraudCheck)        return fraudCheck    }    private fun publishEvent(customerId: String, fraudCheck: FraudCheck) {        val loanApplicationEvent = LoanApplicationEvent(LoanApplication(customerId, fraudCheck))        eventPublisher.publishEvent(loanApplicationEvent)    } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>1.\u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0435\u0441\u0442 spring boot, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430 id &#171;1&#187; \u0441\u0442\u0430\u0442\u0443\u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0436\u043d\u044b\u043c.<\/p>\n<pre><code class=\"kotlin\">@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) class FraudCheckServiceConsumerTest {     @Autowired    private lateinit var fraudCheckService: FraudCheckService     @Test    fun `should return fraud details with status as false for customerId 1`() {        fraudCheckService.isFraudulent(\"1\").status shouldBe false    } }<\/code><\/pre>\n<p>2. \u042d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0430\u043b\u0435\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0441\u043b\u0443\u0436\u0431\u044b \u043f\u043e \u0431\u043e\u0440\u044c\u0431\u0435 \u0441 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c. \u0422\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u043d \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u043b\u0443\u0436\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043c\u043e\u0448\u0435\u043d\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u043e.<\/p>\n<pre><code class=\"kotlin\">@Test fun `should return fraud details with status as false for customerId 1`() {    val mockResponse = MockResponse()        .setBody(\"\"\"{ \"status\": false }\"\"\")        .addHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE)    mockWebServer.enqueue(mockResponse)        fraudCheckService.isFraudulent(\"1\").status shouldBe false } \/\/ Using okhttp3.mockwebserver.MockWebServer<\/code><\/pre>\n<p>3. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442.<\/p>\n<pre><code class=\"kotlin\">@Pact(provider = \"fraud_service\", consumer = \"loan_gateway\") fun nonFraudulentCustomer(pactDsl: PactDslWithProvider): RequestResponsePact {    return pactDsl        .given(\"Customer with id 1 is setup to return false fraudulent status\")        .uponReceiving(\"When fraud status is requested for nonFraudulent customer\")        .method(\"GET\")        .path(\"\/fraud\/1\")        .willRespondWith()        .status(200)        .body(JSONObject(\"\"\"{ \"status\": false }\"\"\"))        .toPact() }<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043e\u0442\u0432\u0435\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u043c \u044d\u0442\u043e \u043f\u043e \u043f\u043e\u043b\u043e\u0447\u043a\u0430\u043c.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>@Pact<\/code>(provider = &#171;fraud_service&#187;, consumer = &#171;loan_gateway&#187;)<\/p>\n<\/td>\n<td>\n<p>\u0418\u043c\u0435\u043d\u0430 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u043c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>given<\/code>(&#171;Customer with id 1 is setup to return false fraudulent status&#187;)<\/p>\n<\/td>\n<td>\n<p>\u0414\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043e\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0432 \u0442\u0435\u0441\u0442\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>uponReceiving<\/code>(&#171;When fraud status is requested for nonFraudulent customer&#187;)<\/p>\n<\/td>\n<td>\n<p>\u042d\u0442\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u043d\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>method<\/code>(&#171;GET&#187;)<\/p>\n<\/td>\n<td>\n<p>Http-\u043c\u0435\u0442\u043e\u0434<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>path<\/code>(&#171;\/fraud\/1&#187;)<\/p>\n<\/td>\n<td>\n<p>Uri-\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>status<\/code>(200)<\/p>\n<\/td>\n<td>\n<p>\u041a\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"337\" width=\"337\">\n<p><code>body<\/code>(JSONObject(&#171;&#187;&#187;{ &#171;status&#187;: false }&#187;&#187;&#187;))<\/p>\n<\/td>\n<td>\n<p>\u0422\u0435\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>4. \u0421\u043d\u0430\u0431\u0434\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>PactTestFor<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0442\u0435\u0441\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a \u043c\u0435\u0442\u043e\u0434\u0443 <code>pact<\/code>.<\/p>\n<p>5. \u0421\u043d\u0430\u0431\u0434\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u0442\u0435\u0441\u0442\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>PactTestFor<\/code>. \u0420\u0430\u0441\u0448\u0438\u0440\u044c\u0442\u0435 \u0442\u0435\u0441\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 <code>PactConsumerTestExt<\/code>.<\/p>\n<p>6. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0442\u0435\u0441\u0442, \u043e\u043d \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c\u00a0 <code>java.net.BindException: Address already in use<\/code>. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e Pact \u0441\u0430\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u043c \u0438\u043c\u0438\u0442\u0430\u0442\u043e\u0440 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0422\u0435\u0441\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"kotlin\">@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @ExtendWith(PactConsumerTestExt::class) @PactTestFor(port = \"1234\") class FraudCheckServiceConsumerTest {     @Autowired    private lateinit var fraudCheckService: FraudCheckService     @Pact(provider = \"fraud_service\", consumer = \"loan_gateway\")    fun nonFraudulentCustomer(pactDsl: PactDslWithProvider): RequestResponsePact {        return pactDsl            .given(\"Customer with id 1 is setup to return false fraudulent status\")            .uponReceiving(\"When fraud status is requested for nonFraudulent customer\")            .method(\"GET\")            .path(\"\/fraud\/1\")            .willRespondWith()            .status(200)            .body(JSONObject(\"\"\"{ \"status\": false }\"\"\"))            .toPact()    }     @Test    @PactTestFor(pactMethod = \"nonFraudulentCustomer\")    fun `should return fraud details with status as false for customerId 1`() {        fraudCheckService.isFraudulent(\"1\").status shouldBe false    } }<\/code><\/pre>\n<p>7. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0442\u0435\u0441\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0431\u043e\u0447\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 \/target\/pacts.<\/p>\n<pre><code class=\"kotlin\">{  \"provider\": {    \"name\": \"fraud_service\"  },  \"consumer\": {    \"name\": \"loan_gateway\"  },  \"interactions\": [    {      \"description\": \"When fraud status is requested for nonFraudulent customer\",      \"request\": {        \"method\": \"GET\",        \"path\": \"\/fraud\/1\"      },      \"response\": {        \"status\": 200,        \"headers\": {          \"Content-Type\": \"application\/json; charset=UTF-8\"        },        \"body\": {          \"status\": false        },        \"matchingRules\": {          \"header\": {            \"Content-Type\": {              \"matchers\": [                {                  \"match\": \"regex\",                  \"regex\": \"application\/json(;\\\\s?charset=[\\\\w\\\\-]+)?\"                }              ],              \"combine\": \"AND\"            }          }        }      },      \"providerStates\": [        {          \"name\": \"Customer with id 1 is setup to return false fraudulent status\"        }      ]    }  ],  \"metadata\": {    \"pactSpecification\": {      \"version\": \"3.0.0\"    },    \"pact-jvm\": {      \"version\": \"4.0.10\"    }  } }<\/code><\/pre>\n<p>8. \u042d\u0442\u043e\u0442 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443, \u0438 \u043e\u043d \u0443\u0431\u0435\u0436\u0434\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0431\u043c\u0435\u043d\u0430 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c\u0438 pact \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0440\u043e\u043a\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u043c\u0443 \u0431\u0440\u043e\u043a\u0435\u0440\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p><strong>\u0422\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430<\/strong><\/p>\n<p>\u0422\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u0440\u043e\u0432\u043d\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0430\u0431\u043e\u0432\/\u043c\u043e\u043a\u043e\u0432. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0443\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430.<\/p>\n<ol>\n<li>\n<p>\u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0435\u0441\u0442 spring boot \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0441\u043b\u0443\u0436\u0431\u044b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <code>FraudServiceController<\/code>. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"kotlin\">@ActiveProfiles(\"test\") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Import(FraudControllerProviderTest.TestConfiguration::class) class FraudControllerProviderTest {    @org.springframework.boot.test.context.TestConfiguration    class TestConfiguration {        @Bean        fun fraudService(): FraudService {            return mockk() {                every { fraudStatus(\"1\") } returns FraudCheck(false)            }        }    } }<\/code><\/pre>\n<p>2. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0442\u0435\u0441\u0442 spring boot \u0432 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441 \u0445\u043e\u0441\u0442\u043e\u043c \u0438 \u043f\u043e\u0440\u0442\u043e\u043c. \u0418 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<\/p>\n<pre><code class=\"kotlin\">@LocalServerPort private val port = 0  @BeforeEach fun before(context: PactVerificationContext) {    context.target = HttpTestTarget(\"localhost\", port) }  @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) {    context.verifyInteraction() }<\/code><\/pre>\n<p>3. \u0421\u0435\u0439\u0447\u0430\u0441 <code>pact<\/code> \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u044d\u0442\u0438\u0445 pact-\u0444\u0430\u0439\u043b\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439.<\/p>\n<pre><code class=\"kotlin\">@PactFolder(\"target\/pacts\") @Provider(\"fraud_service\")<\/code><\/pre>\n<p>4. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0442\u0435\u0441\u0442. \u0422\u0435\u0441\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c <code>au.com.dius.pact.provider.junit.MissingStateChangeMethod: \u041d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d \u043c\u0435\u0442\u043e\u0434 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 @State<\/code><em>(&#171;Customer with id 1 is setup to return false fraudulent status&#187;)<\/em>.<\/p>\n<p>5. \u0412\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <code>state<\/code>, \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b\u0438 \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435 \u0432 \u043f\u0443\u043d\u043a\u0442\u0435 <code>given<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u0435\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041e\u043d\u0430 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443. \u042d\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0443\u0437\u043b\u0435 <code>providerStates<\/code> json \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430.<\/p>\n<p>6. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u0445\u043e\u0442\u044f \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u043e\u043d \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0443\u0436\u0435 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u043b\u0441\u044f \u043c\u043e\u043a. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435, \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0435\u0433\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435.<\/p>\n<pre><code class=\"kotlin\">@State(    value =    [        \"Customer with id 1 is setup to return false fraudulent status\"    ] ) fun setupIfAny() {    \/\/ Nothing to setup as it is taken care by the mock FraudService }<\/code><\/pre>\n<p>7.\u0412\u0435\u0441\u044c \u0442\u0435\u0441\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"kotlin\">@ActiveProfiles(\"test\")<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-385217","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/385217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=385217"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/385217\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=385217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=385217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=385217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}