From d194f64a831e1df2b9abf77cdb04fb88978797ca Mon Sep 17 00:00:00 2001 From: Adam Loup Date: Thu, 19 Sep 2024 07:43:15 -0500 Subject: [PATCH] other test clean up --- .../patient/profile/create/NewPatient.java | 48 +++++++++++++ .../patient/profile/PatientCreateSteps.java | 69 ++++++++----------- 2 files changed, 76 insertions(+), 41 deletions(-) diff --git a/apps/modernization-api/src/main/java/gov/cdc/nbs/patient/profile/create/NewPatient.java b/apps/modernization-api/src/main/java/gov/cdc/nbs/patient/profile/create/NewPatient.java index 3f130b17d3..ed8b0369d9 100644 --- a/apps/modernization-api/src/main/java/gov/cdc/nbs/patient/profile/create/NewPatient.java +++ b/apps/modernization-api/src/main/java/gov/cdc/nbs/patient/profile/create/NewPatient.java @@ -97,6 +97,54 @@ public NewPatient withName(final NameDemographic name) { ); } + public NewPatient withAddress(final Address value) { + return new NewPatient( + administrative(), + birth(), + names(), + Including.include(addresses(), value), + phoneEmails(), + races(), + identifications() + ); + } + + public NewPatient withPhoneEmail(final Phone value) { + return new NewPatient( + administrative(), + birth(), + names(), + addresses(), + Including.include(phoneEmails(), value), + races(), + identifications() + ); + } + + public NewPatient withRace(final Race value) { + return new NewPatient( + administrative(), + birth(), + names(), + addresses(), + phoneEmails(), + Including.include(races(), value), + identifications() + ); + } + + public NewPatient withIdentification(final Identification value) { + return new NewPatient( + administrative(), + birth(), + names(), + addresses(), + phoneEmails(), + races(), + Including.include(identifications(), value) + ); + } + public NewPatient withBirth(final BirthDemographic value) { return new NewPatient( administrative(), diff --git a/apps/modernization-api/src/test/java/gov/cdc/nbs/patient/profile/PatientCreateSteps.java b/apps/modernization-api/src/test/java/gov/cdc/nbs/patient/profile/PatientCreateSteps.java index 30a4f11acb..4b53f87d27 100644 --- a/apps/modernization-api/src/test/java/gov/cdc/nbs/patient/profile/PatientCreateSteps.java +++ b/apps/modernization-api/src/test/java/gov/cdc/nbs/patient/profile/PatientCreateSteps.java @@ -24,8 +24,6 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; -import java.util.Collections; -import java.util.List; import java.util.Locale; import static org.assertj.core.api.Assertions.assertThat; @@ -65,11 +63,8 @@ public void clean() { @Given("I am adding a new patient with addresses") public void i_am_adding_a_new_patient_with_addresses() { - NewPatient newPatient = new NewPatient( - null, - null, - Collections.emptyList(), - List.of( + this.input.active( + current -> current.withAddress( new NewPatient.Address( RandomUtil.getRandomDateInPast(), "H", @@ -84,19 +79,14 @@ public void i_am_adding_a_new_patient_with_addresses() { RandomUtil.country(), RandomUtil.getRandomString() ) - ), Collections.emptyList(), Collections.emptyList(), Collections.emptyList()); - this.input.active(newPatient); - + ) + ); } @Given("I am adding a new patient with emails") public void i_am_adding_a_new_patient_with_emails() { - NewPatient newPatient = new NewPatient( - null, - null, - Collections.emptyList(), - Collections.emptyList(), - List.of( + this.input.active( + current -> current.withPhoneEmail( new NewPatient.Phone( RandomUtil.getRandomDateInPast(), "type-value", @@ -108,21 +98,14 @@ public void i_am_adding_a_new_patient_with_emails() { "url", "comment" ) - ), - Collections.emptyList(), - Collections.emptyList() + ) ); - this.input.active(newPatient); } @Given("I am adding a new patient with phones") public void i_am_adding_a_new_patient_with_phones() { - NewPatient newPatient = new NewPatient( - null, - null, - Collections.emptyList(), - Collections.emptyList(), - List.of( + this.input.active( + current -> current.withPhoneEmail( new NewPatient.Phone( RandomUtil.getRandomDateInPast(), "type-value", @@ -134,31 +117,35 @@ public void i_am_adding_a_new_patient_with_phones() { "url", "comment" ) - ), - Collections.emptyList(), - Collections.emptyList() + ) ); - this.input.active(newPatient); } @Given("I am adding a new patient with races") public void i_am_adding_a_new_patient_with_races() { - NewPatient newPatient = new NewPatient(null,null, null, null, null, List.of(new NewPatient.Race( - RandomUtil.getRandomDateInPast(), - "category-value", - Arrays.asList("detail1", "detail2"))), null); - this.input.active(newPatient); + this.input.active( + current -> current.withRace( + new NewPatient.Race( + RandomUtil.getRandomDateInPast(), + "category-value", + Arrays.asList("detail1", "detail2")) + ) + ); } @Given("I am adding a new patient with identifications") public void i_am_adding_a_new_patient_with_identifications() { - NewPatient newPatient = new NewPatient(null,null, null, null, null, null, List.of(new NewPatient.Identification( - RandomUtil.getRandomDateInPast(), - "DL", - "TX", - "value"))); - this.input.active(newPatient); + this.input.active( + current -> current.withIdentification( + new NewPatient.Identification( + RandomUtil.getRandomDateInPast(), + "DL", + "TX", + "value" + ) + ) + ); } @When("I send a create patient request")