Package org.raxa.module.raxacore

Examples of org.raxa.module.raxacore.DrugInfo


   * Test of getDrugInfo method, of class HibernateDrugInfoDAO.
   */
  @Test
  public void testGetDrugInfo() {
    Integer drugInfoId = 1;
    DrugInfo result = dao.getDrugInfo(drugInfoId);
    String name = result.getName();
    assertEquals("TestDrugInfo1", name);
  }
View Full Code Here


  /**
   * Test of updateDrugInfo method, of class HibernateDrugInfoDAO.
   */
  @Test
  public void testUpdateDrugInfo() {
    DrugInfo drugInfo = dao.getDrugInfo(1);
    drugInfo.setName("NewNameDrugInfo");
    dao.updateDrugInfo(drugInfo);
    String name = dao.getDrugInfo(1).getName();
    assertEquals(name, "NewNameDrugInfo");
  }
View Full Code Here

   */
  private void createNewDrugInfo(Drug drug, LinkedHashMap drugInfoMap) {
    String drugUuid = drug.getUuid();
   
    // create drug info POJO and add required relationship with a Drug
    DrugInfo drugInfo = new DrugInfo();
    drugInfo.setDrug(drug);
    if (drugInfoMap.get("name") != null) {
      drugInfo.setName(drugInfoMap.get("name").toString());
    }
    if (drugInfoMap.get("description") != null) {
      drugInfo.setDescription(drugInfoMap.get("description").toString());
    }
    if (drugInfoMap.get("price") != null) {
      drugInfo.setPrice(Double.parseDouble(drugInfoMap.get("price").toString()));
    }
    if (drugInfoMap.get("cost") != null) {
      drugInfo.setCost(Double.parseDouble(drugInfoMap.get("cost").toString()));
    }
    // save new object and prepare response
    DrugInfo drugInfoJustCreated = Context.getService(DrugInfoService.class).saveDrugInfo(drugInfo);
  }
View Full Code Here

  /**
   * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate()
   */
  @Override
  public DrugInfo newDelegate() {
    return new DrugInfo();
  }
View Full Code Here

  @Test
  public void testSaveDrugInfoShouldUsePrivileges() throws Exception {
    Context.getUserContext().getAuthenticatedUser().removeRole(Context.getUserService().getRole("System Developer"));
    Drug drug = new Drug();
    drug.setId(3);
    DrugInfo drugInfo = new DrugInfo();
    drugInfo.setDrug(drug);
    drugInfo.setName("TestDrugInfo3");
    drugInfo.setDescription("Third Test DrugInfo");
    drugInfo.setCreator(Context.getUserContext().getAuthenticatedUser());
    drugInfo.setDateCreated(new java.util.Date());
    drugInfo.setUuid("68547121-1b70-465c-99ee-c9dfd95e7d30");
    drugInfo.setRetired(Boolean.FALSE);
    try {
      s.saveDrugInfo(drugInfo);
      //if we don't throw exception fail - no privileges required!
      fail("No privileges required for saveDrugInfo");
    }
View Full Code Here

   */
  @Test
  public void testSaveDrugInfoShouldSaveDrugInfo() throws Exception {
    Drug drug = new Drug();
    drug.setId(3);
    DrugInfo drugInfo = new DrugInfo();
    drugInfo.setDrug(drug);
    drugInfo.setName("TestDrugInfo3");
    drugInfo.setDescription("Third Test DrugInfo");
    drugInfo.setCreator(Context.getUserContext().getAuthenticatedUser());
    drugInfo.setDateCreated(new java.util.Date());
    drugInfo.setUuid("68547121-1b70-465c-99ee-c9dfd95e7d30");
    drugInfo.setRetired(Boolean.FALSE);
    s.saveDrugInfo(drugInfo);
    DrugInfo result = s.getDrugInfoByUuid("68547121-1b70-465c-99ee-c9dfd95e7d30");
    String name = result.getName();
    assertEquals(name, "TestDrugInfo3");
  }
View Full Code Here

  @Test
  public void testGetDrugInfoShouldUsePrivileges() {
    Context.getUserContext().getAuthenticatedUser().removeRole(Context.getUserService().getRole("System Developer"));
    Context.getUserContext().removeProxyPrivilege("View Drug Info");
    Integer drugInfoId = 1;
    DrugInfo result = null;
    try {
      result = s.getDrugInfo(drugInfoId);
      //if we don't throw exception fail - no privileges required!
      fail("No privileges required for getDrugInfo");
    }
View Full Code Here

   * Test of getDrugInfo method, of class DrugInfoServiceImpl.
   */
  @Test
  public void testGetDrugInfoShouldReturnDrugInfo() {
    Integer drugInfoId = 1;
    DrugInfo result = s.getDrugInfo(drugInfoId);
    String name = result.getName();
    assertEquals("TestDrugInfo1", name);
  }
View Full Code Here

   */
  @Test
  public void testUpdateDrugInfoShouldUsePrivileges() {
    Context.getUserContext().getAuthenticatedUser().removeRole(Context.getUserService().getRole("System Developer"));
    Context.getUserContext().addProxyPrivilege("View Drug Info");
    DrugInfo drugInfo = s.getDrugInfo(1);
    drugInfo.setName("NewNameDrugInfo");
    try {
      s.updateDrugInfo(drugInfo);
      //if we don't throw exception fail - no privileges required!
      fail("No privileges required for updateDrugInfo");
    }
View Full Code Here

  /**
   * Test of updateDrugInfo method, of class DrugInfoServiceImpl.
   */
  @Test
  public void testUpdateDrugInfoShouldChangeDrugInfo() {
    DrugInfo drugInfo = s.getDrugInfo(1);
    drugInfo.setName("NewNameDrugInfo");
    s.updateDrugInfo(drugInfo);
    String name = s.getDrugInfo(1).getName();
    assertEquals(name, "NewNameDrugInfo");
  }
View Full Code Here

TOP

Related Classes of org.raxa.module.raxacore.DrugInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.