add pact provider test (#3475)
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
b1266c833b
commit
692f12636f
@@ -0,0 +1,32 @@
|
||||
package org.baeldung.web.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.web.dto.PactDto;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class PactController {
|
||||
|
||||
List<PactDto> pacts = new ArrayList<>();
|
||||
|
||||
@GetMapping(value = "/pact", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public PactDto getPact() {
|
||||
return new PactDto(true, "tom");
|
||||
}
|
||||
|
||||
@PostMapping("/pact")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public void createPact(PactDto pact) {
|
||||
pacts.add(pact);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.baeldung.web.dto;
|
||||
|
||||
public class PactDto {
|
||||
|
||||
private boolean condition;
|
||||
private String name;
|
||||
|
||||
public PactDto() {
|
||||
}
|
||||
|
||||
public PactDto(boolean condition, String name) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(boolean condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"provider": {
|
||||
"name": "test_provider"
|
||||
},
|
||||
"consumer": {
|
||||
"name": "test_consumer"
|
||||
},
|
||||
"interactions": [
|
||||
{
|
||||
"description": "GET REQUEST",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"path": "/pact"
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"condition": true,
|
||||
"name": "tom"
|
||||
}
|
||||
},
|
||||
"providerStates": [
|
||||
{
|
||||
"name": "test GET"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "POST REQUEST",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/pact",
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"name": "Michael"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 201
|
||||
},
|
||||
"providerStates": [
|
||||
{
|
||||
"name": "test POST"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"pact-specification": {
|
||||
"version": "3.0.0"
|
||||
},
|
||||
"pact-jvm": {
|
||||
"version": "3.5.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user