示例#1
0
  @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);
  }
示例#2
0
  @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());
  }