<commit_before>package au.com.dius.pact.consumer

import au.com.dius.pact.consumer.dsl.PactDslWithProvider
import au.com.dius.pact.model.PactSpecVersion
import au.com.dius.pact.model.RequestResponsePact
import au.com.dius.pact.model.matchingrules.MatchingRuleGroup
import au.com.dius.pact.model.matchingrules.RegexMatcher
import org.apache.http.HttpStatus
import org.apache.http.client.fluent.Request
import org.apache.http.entity.ContentType
import org.junit.Rule
import org.junit.Test

@SuppressWarnings(['PublicInstanceField', 'NonFinalPublicField', 'JUnitPublicNonTestMethod',
  'JUnitTestMethodWithoutAssert'])
class V2MatchingHeaderTest {

  @Rule
  public PactProviderRuleMk2 provider = new PactProviderRuleMk2('786_provider', PactSpecVersion.V2, this)

  @Pact(provider = '786_provider', consumer = 'test_consumer')
  RequestResponsePact createPact(PactDslWithProvider builder) {
    Map<String, String> headers = ['Header-A': 'A', 'Header-B': 'B']
    RequestResponsePact pact = builder
      .uponReceiving('a request with headers')
      .method('GET')
      .path('/')
      .willRespondWith()
      .status(HttpStatus.SC_OK)
      .body('{}', ContentType.APPLICATION_JSON)
      .headers(headers)
      .matchHeader('Content-Type', 'application/json;\\s?charset=(utf|UTF)-8')
      .toPact()

    assert pact.interactions.first().response.matchingRules.rulesForCategory('header').matchingRules == [
      'Content-Type': new MatchingRuleGroup([new RegexMatcher('application/json;\\s?charset=(utf|UTF)-8')])<commit_msg>fix: invalid imports after merge<commit_after>package au.com.dius.pact.consumer

import au.com.dius.pact.consumer.dsl.PactDslWithProvider
import au.com.dius.pact.core.model.PactSpecVersion
import au.com.dius.pact.core.model.RequestResponsePact
import au.com.dius.pact.core.model.matchingrules.MatchingRuleGroup
import au.com.dius.pact.core.model.matchingrules.RegexMatcher
import org.apache.http.HttpStatus
import org.apache.http.client.fluent.Request
import org.apache.http.entity.ContentType
import org.junit.Rule
import org.junit.Test

@SuppressWarnings(['PublicInstanceField', 'NonFinalPublicField', 'JUnitPublicNonTestMethod',
  'JUnitTestMethodWithoutAssert'])
class V2MatchingHeaderTest {

  @Rule
  public PactProviderRuleMk2 provider = new PactProviderRuleMk2('786_provider', PactSpecVersion.V2, this)

  @Pact(provider = '786_provider', consumer = 'test_consumer')
  RequestResponsePact createPact(PactDslWithProvider builder) {
    Map<String, String> headers = ['Header-A': 'A', 'Header-B': 'B']
    RequestResponsePact pact = builder
      .uponReceiving('a request with headers')
      .method('GET')
      .path('/')
      .willRespondWith()
      .status(HttpStatus.SC_OK)
      .body('{}', ContentType.APPLICATION_JSON)
      .headers(headers)
      .matchHeader('Content-Type', 'application/json;\\s?charset=(utf|UTF)-8')
      .toPact()

    assert pact.interactions.first().response.matchingRules.rulesForCategory('header').matchingRules == [
      'Content-Type': new MatchingRuleGroup([new RegexMatcher('application/json;\\s?charset=(utf|UTF)-8')])
{'fraction_non_alphanumeric': 0.13318284424379231, 'fraction_numerical': 0.007739438890680426, 'mean_word_length': 5.166998011928429, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5048643', 'n_tokens_mistral': 1026, 'n_tokens_neox': 989, 'n_words': 149}