@Test public void testPopulateTo1StrengthNonRecognizedDrug() { DrugTo1 t = new DrugTo1(); Drug d = new Drug(); d.setBrandName("not aspirin"); Boolean resp = this.populateTo1Strength(t, d); assertFalse(resp); }
@Test public void testPopulateDrugStrengthNoStrengthInfo() { Drug d = new Drug(); d.setBrandName("aspirin"); DrugTo1 t = new DrugTo1(); Boolean result = this.populateDrugStrength(d, t); assertEquals("1.0 mg", d.getDosage()); assertEquals("mg", d.getUnit()); assertTrue(result); }
@Test public void testPopulateTo1StrengthNormal() { DrugTo1 t = new DrugTo1(); Drug d = new Drug(); // aspirin will trigger response from MockDrugLookUpManager d.setBrandName("aspirin"); Boolean resp = this.populateTo1Strength(t, d); assertTrue(resp); assertEquals((float) 1.0, t.getStrength()); assertEquals("mg", t.getStrengthUnit()); }
@Test(expected = NumberFormatException.class) public void testInvalidProviderNumberString() { Drug d = new Drug(); LoggedInInfo info = new LoggedInInfo(); Date startDate = new Date(); Date endDate = new Date(); Date archivedDate = new Date(); // SHOULD CAUSE THE EXCEPTION d.setProviderNo("NOT A NUMBER"); // Other fields d.setId(1); d.setDemographicId(1); d.setBrandName("Foobar"); d.setGenericName("Barbang"); d.setRegionalIdentifier("12345"); d.setAtc("abcde"); d.setTakeMax(2); d.setTakeMin(1); d.setRxDate((Date) startDate.clone()); d.setEndDate((Date) endDate.clone()); d.setFreqCode("BID"); d.setDuration("28"); d.setDurUnit("D"); d.setRoute("PO"); d.setDrugForm("TAB"); d.setPrn(true); d.setMethod("Take"); d.setRepeat(5); d.setSpecial("some string"); d.setArchived(false); d.setArchivedDate((Date) archivedDate.clone()); d.setArchivedReason("reason"); DrugTo1 t = this.getAsTransferObject(info, d); }
@Test public void testValidDomainToTransfer() throws Exception { Drug d = new Drug(); LoggedInInfo info = new LoggedInInfo(); Date startDate = new Date(); Date endDate = new Date(); Date archivedDate = new Date(); d.setId(1); d.setDemographicId(1); d.setProviderNo("1"); d.setBrandName("Foobar"); d.setGenericName("Barbang"); d.setRegionalIdentifier("12345"); d.setAtc("abcde"); d.setTakeMax(2); d.setTakeMin(1); d.setRxDate((Date) startDate.clone()); d.setEndDate((Date) endDate.clone()); d.setFreqCode("BID"); d.setDuration("28"); d.setDurUnit("D"); d.setRoute("PO"); d.setDrugForm("TAB"); d.setPrn(true); d.setMethod("Take"); d.setRepeat(5); d.setSpecial("some string"); d.setArchived(false); d.setArchivedDate((Date) archivedDate.clone()); d.setArchivedReason("reason"); DrugTo1 t = this.getAsTransferObject(info, d); assertEquals(1, (int) t.getDrugId()); assertEquals(1, (int) t.getDemographicNo()); assertEquals(1, (int) t.getProviderNo()); assertEquals("Foobar", t.getBrandName()); assertEquals("Barbang", t.getGenericName()); assertEquals("12345", t.getRegionalIdentifier()); assertEquals("abcde", t.getAtc()); assertEquals(1.0, t.getTakeMin(), 0.01); assertEquals(2.0, t.getTakeMax(), 0.01); assertEquals(startDate.toString(), t.getRxDate().toString()); assertEquals(endDate.toString(), t.getEndDate().toString()); assertEquals("BID", t.getFrequency()); assertEquals(28, (int) t.getDuration()); assertEquals("D", t.getDurationUnit()); assertEquals("PO", t.getRoute()); assertEquals("TAB", t.getForm()); assertTrue(t.isPrn()); assertEquals("Take", t.getMethod()); assertEquals(5, (int) t.getRepeats()); assertEquals("some string", t.getInstructions()); assertEquals(archivedDate.toString(), t.getArchivedDate().toString()); assertEquals("reason", t.getArchivedReason()); assertFalse(t.isArchived()); }