DrugGroupServiceImpl implements DrugGroupService { @Override public void deleteDrugGroup(DrugGroup drugGroup) { dao.deleteDrugGroup(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();  }
@Test public void testDeleteDrugGroupShouldUsePrivileges() { Context.getUserContext().getAuthenticatedUser().removeRole(Context.getUserService().getRole("System Developer")); DrugGroup drugGroup = new DrugGroup(); drugGroup.setId(2); drugGroup.setName("TestDrugGroup2"); drugGroup.setDescription("Second Test Drug Group"); drugGroup.setCreator(Context.getUserContext().getAuthenticatedUser()); drugGroup.setDateCreated(new java.util.Date()); drugGroup.setUuid("68547121-1b70-465e-99ee-c9dfd95e7d30"); drugGroup.setRetired(Boolean.FALSE); try { s.deleteDrugGroup(drugGroup); fail("No privileges required for deleteDrugGroup"); } catch (APIAuthenticationException e) { Context.getUserContext().addProxyPrivilege("Delete Drug Groups"); Context.getUserContext().addProxyPrivilege("View Drug Groups"); s.deleteDrugGroup(drugGroup); } }