shouldProduceValidMetricsData.groovy 964 Bytes
Newer Older
1 2
package contracts

3 4
import org.springframework.cloud.netflix.hystrix.contract.HystrixContractUtils

5
org.springframework.cloud.contract.spec.Contract.make {
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
  // Human readable description
  description 'Should produce valid metrics data'
  // Label by means of which the output message can be triggered
  label 'metrics'
  // input to the contract
  input {
    // the contract will be triggered by a method
    triggeredBy('createMetricsData()')
  }
  // output message of the contract
    outputMessage {
        // destination to which the output message will be sent
        sentTo 'hystrixStreamOutput'
        headers {
            header('contentType': 'application/json')
        }
22
        body(HystrixContractUtils.simpleBody())
23 24
        testMatchers {
           jsonPath('$.origin', byCommand('assertOrigin($it)'))
25
           jsonPath('$.event', byCommand('assertEvent($it)'))
26 27 28
           jsonPath('$.data', byCommand('assertData($it)'))
        }
    }
29
}