Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package edu.ncsu.csc.itrust2.cucumber;
- import java.time.LocalDate;
- import org.openqa.selenium.By;
- import org.openqa.selenium.JavascriptExecutor;
- import org.openqa.selenium.WebElement;
- import cucumber.api.java.en.And;
- import cucumber.api.java.en.Given;
- import cucumber.api.java.en.Then;
- import cucumber.api.java.en.When;
- import edu.ncsu.csc.itrust2.models.enums.Gender;
- import edu.ncsu.csc.itrust2.models.enums.Role;
- import edu.ncsu.csc.itrust2.models.persistent.LaborDelivery;
- import edu.ncsu.csc.itrust2.models.persistent.Patient;
- import edu.ncsu.csc.itrust2.models.persistent.User;
- public class LaborDeliveryStepDefs extends CucumberTest {
- /**
- * Creates a female patient with the given userName, firstName, and
- * lastName. Taken from uninitializedPatientExists() in
- * InitializePatientStepDefs.java.
- *
- * @param userName
- * the userName of the patient being made
- * @param firstName
- * the lastName of the patient being made
- * @param lastName
- * the lastName of the patient being made
- *
- */
- @Given ( "^A valid female patient (.+) (.+) (.+) exists in the system.$" )
- public void uninitializedFemalePatientExists ( final String userName, final String firstName,
- final String lastName ) {
- attemptLogout();
- final Patient patient = new Patient();
- patient.setFirstName( firstName );
- final User patientUser = new User( userName, "$2a$10$EblZqNptyYvcLm/VwDCVAuBjzZOI7khzdyGPBr08PpIi0na624b8.",
- Role.ROLE_PATIENT, 1 );
- patientUser.save();
- patient.setSelf( patientUser );
- patient.setGender( Gender.Female );
- patient.setLastName( lastName );
- patient.setDateOfBirth( LocalDate.now().minusYears( 30 ) );
- patient.save();
- }
- @Given ( "^A labor report (.+) with (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+) exists in the system.$" )
- public void laborReportExists ( final String patient, final String date, final String time,
- final String deliveryDate, final String deliveryTime, final String type, final String weight,
- final String length, final String rate, final String systolic, final String diastolic, final String first,
- final String last ) {
- attemptLogout();
- final LaborDelivery laborDelivery = new LaborDelivery();
- laborDelivery.setPatient( patient );
- laborDelivery.setLaborDate( LocalDate.parse(date) );
- laborDelivery.setDeliveryDate( LocalDate.parse(date) );
- laborDelivery.setLaborTime( time );
- laborDelivery.setDeliveryTime( deliveryTime );
- // TODO SET LABOR TIME, SET DELIVERY TIME
- laborDelivery.setWeight( Integer.valueOf( weight ) );
- laborDelivery.setLength( Integer.valueOf( length ) );
- laborDelivery.setHeartRate( Integer.valueOf( rate ) );
- laborDelivery.setSystolic( Integer.valueOf( systolic ) );
- laborDelivery.setDiastolic( Integer.valueOf( diastolic ) );
- laborDelivery.setFirstName( first );
- laborDelivery.setLastName( last );
- laborDelivery.setDeliveryMethod( type );
- laborDelivery.save();
- }
- @When ( "^I navigate to the Obstetrics Records page.$" )
- public void goToObstetricsRecordsPage () {
- ( (JavascriptExecutor) driver ).executeScript( "document.getElementById('HCPObstetricsRecords').click();" );
- waitForAngular();
- }
- @When ( "^I create a lmp for today.$" )
- public void createObstetricsRecord () {
- waitForAngular();
- driver.findElement( By.id( "createObstetricsRecordButton" ) ).click();
- waitForAngular();
- driver.findElement( By.id( "submitObstetricsRecordButton" ) ).click();
- waitForAngular();
- }
- @When ( "^I click the Document Labor and Delivery Report button.$" )
- public void gotoDocumentAndLabor () {
- waitForAngular();
- driver.findElement( By.id( "documentLaborReport" ) ).click();
- }
- @When ( "^I fill in the labor fields date (.+) and time (.+).$" )
- public void fillInLabor ( final String date, final String time ) {
- // fill in labor date & time
- }
- @When ( "^I fill in the delivery fields date (.+) and time (.+), type (.+), weight (.+), length (.+), heart rate (.+), systolic (.+), diastolic (.+), first name (.+), last name (.+).$" )
- public void fillInDelivery ( final String date, final String time, final String type, final String weight,
- final String length, final String heartRate, final String systolic, final String diastolic,
- final String firstName, final String lastName ) {
- // fill in delivery info
- }
- @When ( "^I submit the form.$" )
- public void submitReport () {
- // click submit button
- }
- @Then ( "^The report is successfully created.$" )
- public void checkReportCreated () {
- // assert "Report Created Successfully" on page
- }
- @Then ( "^The mother (.+) is the personal representative of the child (.+) (.+).$" )
- public void motherIsPersonalRepresentative ( final String motherUserName, final String childFirstName,
- final String childLast ) {
- // log in as child and go to personal representatives page
- // check that mother is child's personal representative
- }
- @Then ( "^The report is not successfully created.$" )
- public void invalidReportAdd () {
- // assert "Report Could Not Be Created Successfully" on page
- }
- /////////////
- // Step Defs for view
- ////////////
- @When ( "^I navigate to the View Labor and Delivery Reports page.$" )
- public void gotoLaborDeliveryViewPage () {
- //
- }
- @When ( "^I select the patient (.+) from the edit dropdown menu.$" )
- public void selectPatientEdit ( final String patientUserName ) {
- //
- }
- @When ( "^I select the patient (.+) from the view dropdown menu.$" )
- public void selectPatientView ( final String patientUserName ) {
- //
- }
- @When ( "^I select the date (.+) from the dropdown menu.$" )
- public void selectDateView ( final String date ) {
- //
- }
- @Then ( "^The fields for date (.+) and time (.+) are correct.$" )
- public void checkLabor ( final String date, final String time ) {
- //
- }
- @Then ( "^The fields date (.+) and time (.+), type (.+), weight (.+), length (.+), heart rate (.+), systolic (.+), diastolic (.+), first name (.+), last name (.+) are correct.$" )
- public void checkDelivery ( final String date, final String time, final String type, final String weight,
- final String length, final String heartRate, final String bloodPressure, final String firstName,
- final String lastName ) {
- //
- }
- @When ( "^I log in to iTrust2 as a general HCP.$" )
- public void loginAsGeneralHcp () {
- attemptLogout();
- waitForAngular();
- final WebElement username = driver.findElement( By.name( "username" ) );
- username.clear();
- username.sendKeys( "hcp" );
- final WebElement password = driver.findElement( By.name( "password" ) );
- password.clear();
- password.sendKeys( "123456" );
- final WebElement submit = driver.findElement( By.className( "btn" ) );
- submit.click();
- }
- @When ( "^I log in to iTrust2 with username (.+).$" )
- public void loginAsUser ( final String userName ) {
- attemptLogout();
- waitForAngular();
- final WebElement username = driver.findElement( By.name( "username" ) );
- username.clear();
- username.sendKeys( userName );
- final WebElement password = driver.findElement( By.name( "password" ) );
- password.clear();
- password.sendKeys( "123456" );
- final WebElement submit = driver.findElement( By.className( "btn" ) );
- submit.click();
- }
- @When ( "^I navigate to the patient View Labor and Delivery Reports page.$" )
- public void gotoPatientViewLaborReport () {
- //
- }
- @Then ( "^The report is successfully updated with the new values (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+).$" )
- public void wasSuccessfullyUpdated ( final String date, final String time, final String deliveryDate,
- final String deliveryTime, final String type, final String weight, final String length,
- final String heartRate, final String systolic, final String diastolic, final String firstName,
- final String lastName ) {
- //
- }
- @When ( "^I navigate to the Update Labor Reports Page page.$" )
- public void gotoUpdatePage () {
- //
- }
- @When ( "^I click the Update Labor and Delivery Report button.$" )
- public void clickUpdateButton () {
- //
- }
- @When ( "^I change the report values to (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+).$" )
- public void changeValues ( final String date, final String time, final String deliveryDate,
- final String deliveryTime, final String type, final String weight, final String length,
- final String heartRate, final String systolic, final String diastolic, final String firstName,
- final String lastName ) {
- //
- }
- @And ( "I submit the edit form." )
- public void submitEditForm () {
- //
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement