@Test public void testSaveDrugGroupShouldUsePrivileges() throws Exception { Context.getUserContext().getAuthenticatedUser().removeRole(Context.getUserService().getRole("System Developer")); DrugGroup drugGroup = new DrugGroup(); drugGroup.setName("TestDrugGroup3"); drugGroup.setDescription("Third Test Drug Group"); drugGroup.setCreator(Context.getUserContext().getAuthenticatedUser()); drugGroup.setDateCreated(new java.util.Date()); drugGroup.setUuid("68547121-1b70-465c-99ee-c9dfd95e7d30"); drugGroup.setRetired(Boolean.FALSE); try { s.saveDrugGroup(drugGroup); fail("No privileges required for saveDrugGroup"); } catch (APIAuthenticationException e) { Context.getUserContext().addProxyPrivilege("Add Drug Groups"); Context.getUserContext().addProxyPrivilege("View Drug Groups"); Context.getUserContext().addProxyPrivilege("View Users"); s.saveDrugGroup(drugGroup); } }
@Override public DrugGroup saveDrugGroup(DrugGroup drugGroup) { return dao.saveDrugGroup(drugGroup); }
DrugGroupServiceImpl implements DrugGroupService { @Override public DrugGroup saveDrugGroup(DrugGroup drugGroup) { return dao.saveDrugGroup(drugGroup); } }
DrugGroupServiceImpl implements DrugGroupService { @Override public DrugGroup saveDrugGroup(DrugGroup drugGroup) { return dao.saveDrugGroup(drugGroup); }  }
DrugGroupServiceImpl implements DrugGroupService { @Override public DrugGroup saveDrugGroup(DrugGroup drugGroup) { return dao.saveDrugGroup(drugGroup); }  @Override void setDrugGroupDAO(DrugGroupDAO dao); @Override DrugGroup saveDrugGroup(DrugGroup drugGroup); @Override DrugGroup getDrugGroup(Integer id); @Override List<DrugGroup> getDrugGroupByName(String name); @Override DrugGroup getDrugGroupByUuid(String uuid); @Override List<DrugGroup> getAllDrugGroup(boolean includeRetired); @Override DrugGroup updateDrugGroup(DrugGroup drugGroup); @Override void deleteDrugGroup(DrugGroup drugGroup); @Override void onStartup(); @Override void onShutdown(); }
DrugGroupServiceImpl implements DrugGroupService { @Override public DrugGroup saveDrugGroup(DrugGroup drugGroup) { return dao.saveDrugGroup(drugGroup); }  @Override void setDrugGroupDAO(DrugGroupDAO dao); @Override DrugGroup saveDrugGroup(DrugGroup drugGroup); @Override DrugGroup getDrugGroup(Integer id); @Override List<DrugGroup> getDrugGroupByName(String name); @Override DrugGroup getDrugGroupByUuid(String uuid); @Override List<DrugGroup> getAllDrugGroup(boolean includeRetired); @Override DrugGroup updateDrugGroup(DrugGroup drugGroup); @Override void deleteDrugGroup(DrugGroup drugGroup); @Override void onStartup(); @Override void onShutdown();  }