Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.39 KB | None | 0 0
  1. package test;
  2.  
  3. import java.time.LocalDate;
  4. import java.time.LocalTime;
  5.  
  6. import model.DailyIrregular;
  7. import model.DailyRegular;
  8. import model.Drug;
  9. import model.PN;
  10. import model.Patient;
  11.  
  12. import org.junit.Assert;
  13. import org.junit.Before;
  14. import org.junit.Test;
  15.  
  16. import service.Service;
  17.  
  18. public class TestON
  19. {
  20.  
  21. @Before
  22. public void setUp()
  23. {//
  24. }
  25.  
  26. @Test
  27. public void testcreatePNPrescription()
  28. {
  29. Drug drug = new Drug("Aspirine", 0.3, 0.5, 1, "ml");
  30. Patient patient = new Patient("312321312312", "Nicolas", 60);
  31.  
  32. PN pn = Service.createPNPrescription(LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 3), patient, drug, 3);
  33.  
  34. Assert.assertEquals(pn.getStartDate(),LocalDate.of(2015, 01, 30));
  35. Assert.assertEquals(pn.getEndDate(), LocalDate.of(2015, 02, 3));
  36. Assert.assertEquals(pn.getCountOfUnits(), 3, 0.001);
  37. Assert.assertEquals(pn.getDrug(), drug);
  38. Assert.assertTrue(patient.getPrescriptions().contains(pn));
  39. }
  40.  
  41. @Test
  42. public void createDailyRegularPrescriptionTest()
  43. {
  44. Drug drug = new Drug("Aspirine", 0.3, 0.5, 1, "ml");
  45. Patient patient = new Patient("312321312312", "Nicolas", 60);
  46. DailyRegular dr = Service.createDailyRegularPrescription(LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 3), patient, drug, 2, 0, 1, 2);
  47.  
  48. Assert.assertEquals(dr.getStartDate(), LocalDate.of(2015, 01, 30));
  49. Assert.assertEquals(dr.getEndDate(), LocalDate.of(2015, 02, 3));
  50. Assert.assertEquals(dr.getDrug(), drug);
  51. Assert.assertTrue(patient.getPrescriptions().contains(dr));
  52. }
  53. @Test
  54. public void RecommendedDosePrDayTest()
  55. {
  56. Patient patient1 = new Patient("312321312312", "Nicolas", 0);
  57. Patient patient2 = new Patient("312321312312", "George", 24);
  58. Patient patient3= new Patient("312321312312", "Alladin", 25);
  59. Patient patient4= new Patient("312321312312", "Jane", 120);
  60. Patient patient5= new Patient("312321312312", "Karolis", 121);
  61.  
  62. Drug drug = new Drug("Paracetamol", 3, 2, 1, "ml");
  63.  
  64. Assert.assertEquals(Service.recommendedDosePerDay(patient1, drug), 0, 0.001);
  65. Assert.assertEquals(Service.recommendedDosePerDay(patient2, drug), 72, 0.001);
  66. Assert.assertEquals(Service.recommendedDosePerDay(patient3, drug), 50, 0.001);
  67. Assert.assertEquals(Service.recommendedDosePerDay(patient4, drug), 240, 0.001);
  68. Assert.assertEquals(Service.recommendedDosePerDay(patient5, drug), 121, 0.001);
  69.  
  70. }
  71. @Test
  72. public void CreateDailyIrregularPrescriptionTest() {
  73. Patient patient = Service.createPatient("031414-1578", "Cage", 60);
  74. Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
  75. LocalTime[] hours = { LocalTime.of(8, 30), LocalTime.of(14, 00),
  76. LocalTime.of(19, 00) };
  77. double[] counts = { 1, 4, 6 };
  78. DailyIrregular di = Service.createDailyIrregularPrescription(
  79. LocalDate.of(2015, 03, 24), LocalDate.of(2015, 03, 25),
  80. patient, drug, hours, counts);
  81.  
  82. Assert.assertEquals(di.getStartDate(), LocalDate.of(2015, 03, 24));
  83. Assert.assertEquals(di.getEndDate(), LocalDate.of(2015, 03, 25));
  84. Assert.assertSame(di.getDrug(), drug);
  85. Assert.assertTrue(patient.getPrescriptions().contains(di));
  86.  
  87. }
  88. @Test
  89. public void Dose24DailyRegular()
  90. {
  91. Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
  92.  
  93. Patient patient = new Patient("312321312312", "Nicolas", 60);
  94. DailyRegular dr1 = Service.createDailyRegularPrescription(LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 3), patient, drug, 2, 0, 1, 2);
  95. DailyRegular dr2 = Service.createDailyRegularPrescription(LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 3), patient, drug, 0, 0, 0, 0);
  96. Assert.assertEquals(dr1.dose24(), 5, 0.001);
  97. Assert.assertEquals(dr2.dose24(), 0, 0.001);
  98. }
  99.  
  100. @Test
  101. public void TotalDoseRegular()
  102. {
  103.  
  104. Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
  105.  
  106. Patient patient = new Patient("312321312312", "Nicolas", 60);
  107. DailyRegular dr1 = Service.createDailyRegularPrescription(LocalDate.of(2015, 02, 2), LocalDate.of(2015, 02, 3), patient, drug, 2, 0, 1, 2);
  108. DailyRegular dr2 = Service.createDailyRegularPrescription(LocalDate.of(2015, 02, 2), LocalDate.of(2015, 02, 3), patient, drug, 0, 0, 0, 0);
  109.  
  110. Assert.assertEquals(dr1.totalDose(), 10, 0.001);
  111. Assert.assertEquals(dr2.totalDose(), 0, 0.001);
  112. }
  113.  
  114. @Test
  115. public void Dose24DailyIrregularTest() {
  116. Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
  117. LocalTime[] hours = { LocalTime.of(6, 00), LocalTime.of(9, 00),
  118. LocalTime.of(12, 00), LocalTime.of(15, 00),
  119. LocalTime.of(17, 00), LocalTime.of(19, 00) };
  120. double[] counts1 = { 1, 0, 2, 0, 0, 3 };
  121. double[] counts2 = { 0, 0, 0, 0, 0, 0 };
  122. Patient patient = new Patient("312321312312", "Nicolas", 60);
  123. DailyIrregular di1 = Service.createDailyIrregularPrescription(
  124. LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 02),
  125. patient, drug, hours, counts1);
  126. DailyIrregular di2 = Service.createDailyIrregularPrescription(
  127. LocalDate.of(2015, 01, 20), LocalDate.of(2015, 01, 25),
  128. patient, drug, hours, counts2);
  129. Assert.assertEquals(di1.dose24(), 6, 0.001);
  130. Assert.assertEquals(di2.dose24(), 0, 0.001);
  131. }
  132.  
  133. @Test
  134. public void createDoseTest()
  135. {
  136. Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
  137. DailyIrregular di1 = new DailyIrregular( LocalDate.of(2015, 01, 20), LocalDate.of(2015, 01, 25), drug);
  138. di1.createDose(LocalTime.of(6, 00), 1);
  139.  
  140. Assert.assertEquals(di1.getDoses().size(), 1);
  141. Assert.assertEquals(di1.getDoses().get(0).getCount(), 1, 0.001);
  142. Assert.assertSame(di1.getDoses().get(0).getTime(), LocalTime.of(6, 0));
  143. }
  144. @Test
  145. public void totalDoseDailyIrregularTest() {
  146. Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
  147. LocalTime[] hours = { LocalTime.of(6, 00), LocalTime.of(9, 00),
  148. LocalTime.of(12, 00), LocalTime.of(15, 00),
  149. LocalTime.of(17, 00), LocalTime.of(19, 00) };
  150. double[] counts1 = { 1, 0, 2, 0, 0, 2 };
  151. double[] counts2 = { 0, 0, 0, 0, 0, 0 };
  152. Patient patient = new Patient("312321312312", "Nicolas", 60);
  153. DailyIrregular di1 = Service.createDailyIrregularPrescription(
  154. LocalDate.of(2015, 01, 28), LocalDate.of(2015, 01, 29),
  155. patient, drug, hours, counts1);
  156. DailyIrregular di2 = Service.createDailyIrregularPrescription(
  157. LocalDate.of(2015, 01, 23), LocalDate.of(2015, 01, 24),
  158. patient, drug, hours, counts2);
  159. Assert.assertEquals(di1.totalDose(), 10, 0.001);
  160. Assert.assertEquals(di2.totalDose(), 0, 0.001);
  161. }
  162. @Test
  163. public void giveDoseTest()
  164. {
  165. Patient patient = Service.createPatient("031414-1578", "Cage", 60);
  166. Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
  167. PN pn = Service.createPNPrescription(LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 3), patient, drug, 3);
  168.  
  169.  
  170.  
  171. }
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement