Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test;
- import java.time.LocalDate;
- import java.time.LocalTime;
- import model.DailyIrregular;
- import model.DailyRegular;
- import model.Drug;
- import model.PN;
- import model.Patient;
- import org.junit.Assert;
- import org.junit.Before;
- import org.junit.Test;
- import service.Service;
- public class TestON
- {
- @Before
- public void setUp()
- {//
- }
- @Test
- public void testcreatePNPrescription()
- {
- Drug drug = new Drug("Aspirine", 0.3, 0.5, 1, "ml");
- Patient patient = new Patient("312321312312", "Nicolas", 60);
- PN pn = Service.createPNPrescription(LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 3), patient, drug, 3);
- Assert.assertEquals(pn.getStartDate(),LocalDate.of(2015, 01, 30));
- Assert.assertEquals(pn.getEndDate(), LocalDate.of(2015, 02, 3));
- Assert.assertEquals(pn.getCountOfUnits(), 3, 0.001);
- Assert.assertEquals(pn.getDrug(), drug);
- Assert.assertTrue(patient.getPrescriptions().contains(pn));
- }
- @Test
- public void createDailyRegularPrescriptionTest()
- {
- Drug drug = new Drug("Aspirine", 0.3, 0.5, 1, "ml");
- Patient patient = new Patient("312321312312", "Nicolas", 60);
- DailyRegular dr = Service.createDailyRegularPrescription(LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 3), patient, drug, 2, 0, 1, 2);
- Assert.assertEquals(dr.getStartDate(), LocalDate.of(2015, 01, 30));
- Assert.assertEquals(dr.getEndDate(), LocalDate.of(2015, 02, 3));
- Assert.assertEquals(dr.getDrug(), drug);
- Assert.assertTrue(patient.getPrescriptions().contains(dr));
- }
- @Test
- public void RecommendedDosePrDayTest()
- {
- Patient patient1 = new Patient("312321312312", "Nicolas", 0);
- Patient patient2 = new Patient("312321312312", "George", 24);
- Patient patient3= new Patient("312321312312", "Alladin", 25);
- Patient patient4= new Patient("312321312312", "Jane", 120);
- Patient patient5= new Patient("312321312312", "Karolis", 121);
- Drug drug = new Drug("Paracetamol", 3, 2, 1, "ml");
- Assert.assertEquals(Service.recommendedDosePerDay(patient1, drug), 0, 0.001);
- Assert.assertEquals(Service.recommendedDosePerDay(patient2, drug), 72, 0.001);
- Assert.assertEquals(Service.recommendedDosePerDay(patient3, drug), 50, 0.001);
- Assert.assertEquals(Service.recommendedDosePerDay(patient4, drug), 240, 0.001);
- Assert.assertEquals(Service.recommendedDosePerDay(patient5, drug), 121, 0.001);
- }
- @Test
- public void CreateDailyIrregularPrescriptionTest() {
- Patient patient = Service.createPatient("031414-1578", "Cage", 60);
- Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
- LocalTime[] hours = { LocalTime.of(8, 30), LocalTime.of(14, 00),
- LocalTime.of(19, 00) };
- double[] counts = { 1, 4, 6 };
- DailyIrregular di = Service.createDailyIrregularPrescription(
- LocalDate.of(2015, 03, 24), LocalDate.of(2015, 03, 25),
- patient, drug, hours, counts);
- Assert.assertEquals(di.getStartDate(), LocalDate.of(2015, 03, 24));
- Assert.assertEquals(di.getEndDate(), LocalDate.of(2015, 03, 25));
- Assert.assertSame(di.getDrug(), drug);
- Assert.assertTrue(patient.getPrescriptions().contains(di));
- }
- @Test
- public void Dose24DailyRegular()
- {
- Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
- Patient patient = new Patient("312321312312", "Nicolas", 60);
- DailyRegular dr1 = Service.createDailyRegularPrescription(LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 3), patient, drug, 2, 0, 1, 2);
- DailyRegular dr2 = Service.createDailyRegularPrescription(LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 3), patient, drug, 0, 0, 0, 0);
- Assert.assertEquals(dr1.dose24(), 5, 0.001);
- Assert.assertEquals(dr2.dose24(), 0, 0.001);
- }
- @Test
- public void TotalDoseRegular()
- {
- Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
- Patient patient = new Patient("312321312312", "Nicolas", 60);
- DailyRegular dr1 = Service.createDailyRegularPrescription(LocalDate.of(2015, 02, 2), LocalDate.of(2015, 02, 3), patient, drug, 2, 0, 1, 2);
- DailyRegular dr2 = Service.createDailyRegularPrescription(LocalDate.of(2015, 02, 2), LocalDate.of(2015, 02, 3), patient, drug, 0, 0, 0, 0);
- Assert.assertEquals(dr1.totalDose(), 10, 0.001);
- Assert.assertEquals(dr2.totalDose(), 0, 0.001);
- }
- @Test
- public void Dose24DailyIrregularTest() {
- Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
- LocalTime[] hours = { LocalTime.of(6, 00), LocalTime.of(9, 00),
- LocalTime.of(12, 00), LocalTime.of(15, 00),
- LocalTime.of(17, 00), LocalTime.of(19, 00) };
- double[] counts1 = { 1, 0, 2, 0, 0, 3 };
- double[] counts2 = { 0, 0, 0, 0, 0, 0 };
- Patient patient = new Patient("312321312312", "Nicolas", 60);
- DailyIrregular di1 = Service.createDailyIrregularPrescription(
- LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 02),
- patient, drug, hours, counts1);
- DailyIrregular di2 = Service.createDailyIrregularPrescription(
- LocalDate.of(2015, 01, 20), LocalDate.of(2015, 01, 25),
- patient, drug, hours, counts2);
- Assert.assertEquals(di1.dose24(), 6, 0.001);
- Assert.assertEquals(di2.dose24(), 0, 0.001);
- }
- @Test
- public void createDoseTest()
- {
- Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
- DailyIrregular di1 = new DailyIrregular( LocalDate.of(2015, 01, 20), LocalDate.of(2015, 01, 25), drug);
- di1.createDose(LocalTime.of(6, 00), 1);
- Assert.assertEquals(di1.getDoses().size(), 1);
- Assert.assertEquals(di1.getDoses().get(0).getCount(), 1, 0.001);
- Assert.assertSame(di1.getDoses().get(0).getTime(), LocalTime.of(6, 0));
- }
- @Test
- public void totalDoseDailyIrregularTest() {
- Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
- LocalTime[] hours = { LocalTime.of(6, 00), LocalTime.of(9, 00),
- LocalTime.of(12, 00), LocalTime.of(15, 00),
- LocalTime.of(17, 00), LocalTime.of(19, 00) };
- double[] counts1 = { 1, 0, 2, 0, 0, 2 };
- double[] counts2 = { 0, 0, 0, 0, 0, 0 };
- Patient patient = new Patient("312321312312", "Nicolas", 60);
- DailyIrregular di1 = Service.createDailyIrregularPrescription(
- LocalDate.of(2015, 01, 28), LocalDate.of(2015, 01, 29),
- patient, drug, hours, counts1);
- DailyIrregular di2 = Service.createDailyIrregularPrescription(
- LocalDate.of(2015, 01, 23), LocalDate.of(2015, 01, 24),
- patient, drug, hours, counts2);
- Assert.assertEquals(di1.totalDose(), 10, 0.001);
- Assert.assertEquals(di2.totalDose(), 0, 0.001);
- }
- @Test
- public void giveDoseTest()
- {
- Patient patient = Service.createPatient("031414-1578", "Cage", 60);
- Drug drug = Service.createDrug("Antibiotics", 0.25, 0.50, 0.75, "mL");
- PN pn = Service.createPNPrescription(LocalDate.of(2015, 01, 30), LocalDate.of(2015, 02, 3), patient, drug, 3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement