### Question:
DBPolicyManager extends DBManager<Policy> implements PolicyManager { @Override public final Policy getDefaultPolicy(final Appraiser appraiser) { if (appraiser == null) { LOGGER.error("cannot get default policy for null appraiser"); return null; } Policy ret = null; final SessionFactory factory = getFactory(); Transaction tx = null; Session session = factory.getCurrentSession(); try { tx = session.beginTransaction(); LOGGER.debug("retrieving policy mapper from db where appraiser = {}", appraiser); final Criteria cr = session.createCriteria(PolicyMapper.class) .createAlias("deviceGroup", "group") .add(Restrictions.eq("appraiser", appraiser)) .add(Restrictions.eq("group.name", DeviceGroup.DEFAULT_GROUP)); final PolicyMapper mapper = (PolicyMapper) cr.uniqueResult(); if (mapper == null) { LOGGER.debug("no policy mapper found for appraiser {}", appraiser); } else { ret = mapper.getPolicy(); } session.getTransaction().commit(); } catch (Exception e) { final String msg = "unable to get default policy"; LOGGER.error(msg, e); if (tx != null) { LOGGER.debug("rolling back transaction"); tx.rollback(); } throw new DBManagerException(msg, e); } return ret; } DBPolicyManager(final SessionFactory factory); @Override final Policy savePolicy(final Policy policy); @Override final void updatePolicy(final Policy policy); @Override final List<Policy> getPolicyList(final Class<? extends Policy> clazz); @Override List<Policy> getPoliciesContainingBaseline(
            final Class<? extends Policy> clazz,
            final Baseline baseline
    ); @Override final Policy getPolicy(final String name); @Override final Policy getPolicy(final Serializable id); @Override final void setDefaultPolicy(final Appraiser appraiser,
            final Policy policy); @Override final Policy getCompletePolicy(final String name); @Override final Policy getDefaultPolicy(final Appraiser appraiser); @Override final Policy getPolicy(
            final Appraiser appraiser,
            final Device device); @Override final Policy getPolicy(final Appraiser appraiser,
            final DeviceGroup deviceGroup); @Override final void setPolicy(final Appraiser appraiser,
            final DeviceGroup deviceGroup, final Policy policy); final int getGroupCountForPolicy(final Policy policy);  }### Answer:
@Test public void testGetDefaultPolicyNullAppraiser() { final PolicyManager mgr = new DBPolicyManager(sessionFactory); final Policy policy = mgr.getDefaultPolicy(null); Assert.assertNull(policy); }
@Test public void testGetDefaultPolicyNoneSet() { final PolicyManager mgr = new DBPolicyManager(sessionFactory); final Policy policy = mgr.getDefaultPolicy(appraiser); Assert.assertNull(policy); }