Skip to content

Commit

Permalink
Get snapshotId from provider state
Browse files Browse the repository at this point in the history
  • Loading branch information
samanehsan committed Jan 23, 2024
1 parent 317dc35 commit 0b7cf3b
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/test/java/bio/terra/pact/consumer/TpsPactTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ class TpsPactTest {
.updateMode(PolicyService.UPDATE_MODE)
.addAttributes(new TpsPolicyInputs().addInputsItem(groupConstraintPolicy));

private String createPaoProtectedDataJson;
private String createPaoGroupConstraintJson;
private String updatePaoJson;

ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);

@BeforeEach
Expand Down Expand Up @@ -108,12 +104,11 @@ RequestResponsePact createPaoConflict(PactDslWithProvider builder)
RequestResponsePact updatePao(PactDslWithProvider builder) throws JsonProcessingException {
String updatePaoJson = mapper.writeValueAsString(updatePAORequest);
return builder
.given(
"a PAO with a protected-data policy exists for this snapshot",
Map.of("id", snapshotId.toString()))
.given("a PAO with a protected-data policy exists for this snapshot")
.uponReceiving("update snapshot PAO with group constraint policy")
.method("PATCH")
.path("/api/policy/v1alpha1/pao/" + snapshotId)
.pathFromProviderState(
"/api/policy/v1alpha1/pao/${snapshotId}", "/api/policy/v1alpha1/pao/" + snapshotId)
.body(updatePaoJson)
.headers(contentTypeJsonHeader)
.willRespondWith()
Expand All @@ -127,12 +122,11 @@ RequestResponsePact updatePaoConflict(PactDslWithProvider builder)
throws JsonProcessingException {
String updatePaoJson = mapper.writeValueAsString(updatePAORequest);
return builder
.given(
"a PAO with a group constraint policy exists for this snapshot",
Map.of("id", snapshotId.toString()))
.given("a PAO with a group constraint policy exists for this snapshot")
.uponReceiving("update snapshot PAO with duplicate group constraint policy")
.method("PATCH")
.path("/api/policy/v1alpha1/pao/" + snapshotId)
.pathFromProviderState(
"/api/policy/v1alpha1/pao/${snapshotId}", "/api/policy/v1alpha1/pao/" + snapshotId)
.body(updatePaoJson)
.headers(contentTypeJsonHeader)
.willRespondWith()
Expand All @@ -143,10 +137,11 @@ RequestResponsePact updatePaoConflict(PactDslWithProvider builder)
@Pact(consumer = "datarepo")
RequestResponsePact deletePao(PactDslWithProvider builder) {
return builder
.given("a PAO with this id exists", Map.of("id", snapshotId.toString()))
.given("a PAO with this id exists")
.uponReceiving("delete PAO")
.method("DELETE")
.path("/api/policy/v1alpha1/pao/" + snapshotId)
.pathFromProviderState(
"/api/policy/v1alpha1/pao/${snapshotId}", "/api/policy/v1alpha1/pao/" + snapshotId)
.willRespondWith()
.status(200)
.toPact();
Expand All @@ -155,10 +150,11 @@ RequestResponsePact deletePao(PactDslWithProvider builder) {
@Pact(consumer = "datarepo")
RequestResponsePact deletePaoThatDoesNotExist(PactDslWithProvider builder) {
return builder
.given("a PAO with this id does not exist", Map.of("id", snapshotId.toString()))
.given("a PAO with this id does not exist")
.uponReceiving("delete non-existent PAO")
.method("DELETE")
.path("/api/policy/v1alpha1/pao/" + snapshotId)
.pathFromProviderState(
"/api/policy/v1alpha1/pao/${snapshotId}", "/api/policy/v1alpha1/pao/" + snapshotId)
.willRespondWith()
.status(404)
.toPact();
Expand Down

0 comments on commit 0b7cf3b

Please sign in to comment.