Advertisement
Guest User

Untitled

a guest
Apr 15th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.41 KB | None | 0 0
  1. package edu.ncsu.csc.itrust2.cucumber;
  2.  
  3. import java.time.LocalDate;
  4.  
  5. import org.openqa.selenium.By;
  6. import org.openqa.selenium.JavascriptExecutor;
  7. import org.openqa.selenium.WebElement;
  8.  
  9. import cucumber.api.java.en.And;
  10. import cucumber.api.java.en.Given;
  11. import cucumber.api.java.en.Then;
  12. import cucumber.api.java.en.When;
  13. import edu.ncsu.csc.itrust2.models.enums.Gender;
  14. import edu.ncsu.csc.itrust2.models.enums.Role;
  15. import edu.ncsu.csc.itrust2.models.persistent.LaborDelivery;
  16. import edu.ncsu.csc.itrust2.models.persistent.Patient;
  17. import edu.ncsu.csc.itrust2.models.persistent.User;
  18.  
  19. public class LaborDeliveryStepDefs extends CucumberTest {
  20.  
  21. /**
  22. * Creates a female patient with the given userName, firstName, and
  23. * lastName. Taken from uninitializedPatientExists() in
  24. * InitializePatientStepDefs.java.
  25. *
  26. * @param userName
  27. * the userName of the patient being made
  28. * @param firstName
  29. * the lastName of the patient being made
  30. * @param lastName
  31. * the lastName of the patient being made
  32. *
  33. */
  34. @Given ( "^A valid female patient (.+) (.+) (.+) exists in the system.$" )
  35. public void uninitializedFemalePatientExists ( final String userName, final String firstName,
  36. final String lastName ) {
  37. attemptLogout();
  38. final Patient patient = new Patient();
  39. patient.setFirstName( firstName );
  40. final User patientUser = new User( userName, "$2a$10$EblZqNptyYvcLm/VwDCVAuBjzZOI7khzdyGPBr08PpIi0na624b8.",
  41. Role.ROLE_PATIENT, 1 );
  42. patientUser.save();
  43. patient.setSelf( patientUser );
  44. patient.setGender( Gender.Female );
  45. patient.setLastName( lastName );
  46. patient.setDateOfBirth( LocalDate.now().minusYears( 30 ) );
  47. patient.save();
  48.  
  49. }
  50.  
  51. @Given ( "^A labor report (.+) with (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+) exists in the system.$" )
  52. public void laborReportExists ( final String patient, final String date, final String time,
  53. final String deliveryDate, final String deliveryTime, final String type, final String weight,
  54. final String length, final String rate, final String systolic, final String diastolic, final String first,
  55. final String last ) {
  56. attemptLogout();
  57. final LaborDelivery laborDelivery = new LaborDelivery();
  58. laborDelivery.setPatient( patient );
  59. laborDelivery.setLaborDate( LocalDate.parse(date) );
  60. laborDelivery.setDeliveryDate( LocalDate.parse(date) );
  61. laborDelivery.setLaborTime( time );
  62. laborDelivery.setDeliveryTime( deliveryTime );
  63. // TODO SET LABOR TIME, SET DELIVERY TIME
  64. laborDelivery.setWeight( Integer.valueOf( weight ) );
  65. laborDelivery.setLength( Integer.valueOf( length ) );
  66. laborDelivery.setHeartRate( Integer.valueOf( rate ) );
  67. laborDelivery.setSystolic( Integer.valueOf( systolic ) );
  68. laborDelivery.setDiastolic( Integer.valueOf( diastolic ) );
  69. laborDelivery.setFirstName( first );
  70. laborDelivery.setLastName( last );
  71. laborDelivery.setDeliveryMethod( type );
  72. laborDelivery.save();
  73.  
  74. }
  75.  
  76. @When ( "^I navigate to the Obstetrics Records page.$" )
  77. public void goToObstetricsRecordsPage () {
  78. ( (JavascriptExecutor) driver ).executeScript( "document.getElementById('HCPObstetricsRecords').click();" );
  79. waitForAngular();
  80. }
  81.  
  82. @When ( "^I create a lmp for today.$" )
  83. public void createObstetricsRecord () {
  84. waitForAngular();
  85. driver.findElement( By.id( "createObstetricsRecordButton" ) ).click();
  86. waitForAngular();
  87. driver.findElement( By.id( "submitObstetricsRecordButton" ) ).click();
  88. waitForAngular();
  89. }
  90.  
  91. @When ( "^I click the Document Labor and Delivery Report button.$" )
  92. public void gotoDocumentAndLabor () {
  93. waitForAngular();
  94. driver.findElement( By.id( "documentLaborReport" ) ).click();
  95. }
  96.  
  97. @When ( "^I fill in the labor fields date (.+) and time (.+).$" )
  98. public void fillInLabor ( final String date, final String time ) {
  99. // fill in labor date & time
  100. }
  101.  
  102. @When ( "^I fill in the delivery fields date (.+) and time (.+), type (.+), weight (.+), length (.+), heart rate (.+), systolic (.+), diastolic (.+), first name (.+), last name (.+).$" )
  103. public void fillInDelivery ( final String date, final String time, final String type, final String weight,
  104. final String length, final String heartRate, final String systolic, final String diastolic,
  105. final String firstName, final String lastName ) {
  106. // fill in delivery info
  107. }
  108.  
  109. @When ( "^I submit the form.$" )
  110. public void submitReport () {
  111. // click submit button
  112. }
  113.  
  114. @Then ( "^The report is successfully created.$" )
  115. public void checkReportCreated () {
  116. // assert "Report Created Successfully" on page
  117. }
  118.  
  119. @Then ( "^The mother (.+) is the personal representative of the child (.+) (.+).$" )
  120. public void motherIsPersonalRepresentative ( final String motherUserName, final String childFirstName,
  121. final String childLast ) {
  122. // log in as child and go to personal representatives page
  123. // check that mother is child's personal representative
  124. }
  125.  
  126. @Then ( "^The report is not successfully created.$" )
  127. public void invalidReportAdd () {
  128. // assert "Report Could Not Be Created Successfully" on page
  129. }
  130. /////////////
  131. // Step Defs for view
  132. ////////////
  133.  
  134. @When ( "^I navigate to the View Labor and Delivery Reports page.$" )
  135. public void gotoLaborDeliveryViewPage () {
  136. //
  137. }
  138.  
  139. @When ( "^I select the patient (.+) from the edit dropdown menu.$" )
  140. public void selectPatientEdit ( final String patientUserName ) {
  141. //
  142. }
  143.  
  144. @When ( "^I select the patient (.+) from the view dropdown menu.$" )
  145. public void selectPatientView ( final String patientUserName ) {
  146. //
  147. }
  148.  
  149. @When ( "^I select the date (.+) from the dropdown menu.$" )
  150. public void selectDateView ( final String date ) {
  151. //
  152. }
  153.  
  154. @Then ( "^The fields for date (.+) and time (.+) are correct.$" )
  155. public void checkLabor ( final String date, final String time ) {
  156. //
  157. }
  158.  
  159. @Then ( "^The fields date (.+) and time (.+), type (.+), weight (.+), length (.+), heart rate (.+), systolic (.+), diastolic (.+), first name (.+), last name (.+) are correct.$" )
  160. public void checkDelivery ( final String date, final String time, final String type, final String weight,
  161. final String length, final String heartRate, final String bloodPressure, final String firstName,
  162. final String lastName ) {
  163. //
  164. }
  165.  
  166. @When ( "^I log in to iTrust2 as a general HCP.$" )
  167. public void loginAsGeneralHcp () {
  168. attemptLogout();
  169. waitForAngular();
  170. final WebElement username = driver.findElement( By.name( "username" ) );
  171. username.clear();
  172. username.sendKeys( "hcp" );
  173. final WebElement password = driver.findElement( By.name( "password" ) );
  174. password.clear();
  175. password.sendKeys( "123456" );
  176. final WebElement submit = driver.findElement( By.className( "btn" ) );
  177. submit.click();
  178.  
  179. }
  180.  
  181. @When ( "^I log in to iTrust2 with username (.+).$" )
  182. public void loginAsUser ( final String userName ) {
  183. attemptLogout();
  184. waitForAngular();
  185. final WebElement username = driver.findElement( By.name( "username" ) );
  186. username.clear();
  187. username.sendKeys( userName );
  188. final WebElement password = driver.findElement( By.name( "password" ) );
  189. password.clear();
  190. password.sendKeys( "123456" );
  191. final WebElement submit = driver.findElement( By.className( "btn" ) );
  192. submit.click();
  193. }
  194.  
  195. @When ( "^I navigate to the patient View Labor and Delivery Reports page.$" )
  196. public void gotoPatientViewLaborReport () {
  197. //
  198. }
  199.  
  200. @Then ( "^The report is successfully updated with the new values (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+).$" )
  201. public void wasSuccessfullyUpdated ( final String date, final String time, final String deliveryDate,
  202. final String deliveryTime, final String type, final String weight, final String length,
  203. final String heartRate, final String systolic, final String diastolic, final String firstName,
  204. final String lastName ) {
  205. //
  206. }
  207.  
  208. @When ( "^I navigate to the Update Labor Reports Page page.$" )
  209. public void gotoUpdatePage () {
  210. //
  211. }
  212.  
  213. @When ( "^I click the Update Labor and Delivery Report button.$" )
  214. public void clickUpdateButton () {
  215. //
  216. }
  217.  
  218. @When ( "^I change the report values to (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+), (.+).$" )
  219. public void changeValues ( final String date, final String time, final String deliveryDate,
  220. final String deliveryTime, final String type, final String weight, final String length,
  221. final String heartRate, final String systolic, final String diastolic, final String firstName,
  222. final String lastName ) {
  223. //
  224. }
  225.  
  226. @And ( "I submit the edit form." )
  227. public void submitEditForm () {
  228. //
  229. }
  230. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement