Removing the Pact integration; fixes gh-1845

This commit is contained in:
Marcin Grzejszczak
2022-11-17 16:01:40 +01:00
parent cff332fc40
commit dc581e8934
66 changed files with 4 additions and 6689 deletions

View File

@@ -96,14 +96,6 @@
<packageWithBaseClasses>com.example.fraud</packageWithBaseClasses>
<!-- <convertToYaml>true</convertToYaml>-->
</configuration>
<!-- if additional dependencies are needed e.g. for Pact -->
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-pact</artifactId>
<version>${spring-cloud-contract.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- end::contract_maven_plugin[] -->
<plugin>

View File

@@ -51,11 +51,6 @@ public class FraudDetectionController {
// end::initial_impl[]
}
@RequestMapping(value = "/pactfraudcheck", method = PUT)
public FraudCheckResult pactFraudCheck(@RequestBody FraudCheck fraudCheck) {
return fraudCheck(fraudCheck);
}
@RequestMapping(value = "/yamlfraudcheck", method = PUT)
public FraudCheckResult yamlFraudCheck(@RequestBody FraudCheck fraudCheck) {
return fraudCheck(fraudCheck);

View File

@@ -46,11 +46,6 @@ public class FraudStatsController {
return new Response(this.statsProvider.count(FraudType.ALL));
}
@GetMapping(value = "/pactfrauds")
public Response countAllPactFrauds() {
return countAllFrauds();
}
@GetMapping(value = "/yamlfrauds")
public Response countAllYamlFrauds() {
return countAllFrauds();
@@ -61,11 +56,6 @@ public class FraudStatsController {
return new Response(this.statsProvider.count(FraudType.DRUNKS));
}
@GetMapping(value = "/pactdrunks")
public Response countAllPactDrunks() {
return countAllDrunks();
}
@GetMapping(value = "/yamldrunks")
public Response countAllYamlDrunks() {
return countAllDrunks();
@@ -101,4 +91,4 @@ class DefaultStatsProvider implements StatsProvider {
public int count(FraudType fraudType) {
return 0;
}
}
}

View File

@@ -1,46 +0,0 @@
/*
* Copyright 2013-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.fraud;
import io.restassured.module.mockmvc.RestAssuredMockMvc;
import org.junit.jupiter.api.BeforeEach;
public class PactBase {
@BeforeEach
public void setup() {
RestAssuredMockMvc.standaloneSetup(new FraudDetectionController(),
new FraudStatsController(stubbedStatsProvider()));
}
private StatsProvider stubbedStatsProvider() {
return fraudType -> {
switch (fraudType) {
case DRUNKS:
return 100;
case ALL:
return 200;
}
return 0;
};
}
public void assertThatRejectionReasonIsNull(Object rejectionReason) {
assert rejectionReason == null;
}
}

View File

@@ -1,98 +0,0 @@
{
"provider": {
"name": "Provider"
},
"consumer": {
"name": "Consumer"
},
"interactions": [
{
"description": "",
"request": {
"method": "PUT",
"path": "/pactfraudcheck",
"headers": {
"Content-Type": "application/json"
},
"body": {
"clientId": "1234567890",
"loanAmount": 99999
},
"generators": {
"body": {
"$.clientId": {
"type": "Regex",
"regex": "[0-9]{10}"
}
}
},
"matchingRules": {
"header": {
"Content-Type": {
"matchers": [
{
"match": "regex",
"regex": "application/json.*"
}
],
"combine": "AND"
}
},
"body": {
"$.clientId": {
"matchers": [
{
"match": "regex",
"regex": "[0-9]{10}"
}
],
"combine": "AND"
}
}
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"fraudCheckStatus": "FRAUD",
"rejection.reason": "Amount too high"
},
"matchingRules": {
"header": {
"Content-Type": {
"matchers": [
{
"match": "regex",
"regex": "application/json.*"
}
],
"combine": "AND"
}
},
"body": {
"$.fraudCheckStatus": {
"matchers": [
{
"match": "regex",
"regex": "FRAUD"
}
],
"combine": "AND"
}
}
}
}
}
],
"metadata": {
"pact-specification": {
"version": "3.0.0"
},
"pact-jvm": {
"version": "3.5.13"
}
}
}

View File

@@ -1,42 +0,0 @@
{
"provider": {
"name": "Provider"
},
"consumer": {
"name": "Consumer"
},
"interactions": [
{
"description": "",
"request": {
"method": "PUT",
"path": "/pactfraudcheck",
"headers": {
"Content-Type": "application/json"
},
"body": {
"clientId": "1234567890",
"loanAmount": 123.123
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"fraudCheckStatus": "OK",
"rejection.reason": null
}
}
}
],
"metadata": {
"pact-specification": {
"version": "2.0.0"
},
"pact-jvm": {
"version": "2.4.18"
}
}
}

View File

@@ -1,34 +0,0 @@
{
"provider": {
"name": "Provider"
},
"consumer": {
"name": "Consumer"
},
"interactions": [
{
"description": "",
"request": {
"method": "GET",
"path": "/pactdrunks"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"count": 100
}
}
}
],
"metadata": {
"pact-specification": {
"version": "2.0.0"
},
"pact-jvm": {
"version": "2.4.18"
}
}
}

View File

@@ -1,34 +0,0 @@
{
"provider": {
"name": "Provider"
},
"consumer": {
"name": "Consumer"
},
"interactions": [
{
"description": "",
"request": {
"method": "GET",
"path": "/pactfrauds"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"count": 200
}
}
}
],
"metadata": {
"pact-specification": {
"version": "2.0.0"
},
"pact-jvm": {
"version": "2.4.18"
}
}
}