### Question:
DBDeviceStateManager extends DBManager<DeviceState> implements DeviceStateManager { @Override public final DeviceState getState(final Device device, final Class<? extends DeviceState> clazz) throws DeviceStateManagerException { LOGGER.debug("getting state for device: {}", device); if (device == null) { LOGGER.error("null device argument"); throw new NullPointerException("null device"); } DeviceState ret; Transaction tx = null; Session session = getFactory().getCurrentSession(); try { LOGGER.debug("retrieving state from db"); tx = session.beginTransaction(); ret = (DeviceState) session.createCriteria(clazz) .add(Restrictions.eq("device", device)).uniqueResult(); tx.commit(); } catch (Exception e) { final String msg = "unable to retrieve object"; LOGGER.error(msg, e); if (tx != null) { LOGGER.debug("rolling back transaction"); tx.rollback(); } throw new DBManagerException(msg, e); } return ret; } DBDeviceStateManager(final SessionFactory sessionFactory); @Override final DeviceState saveState(final DeviceState state); @Override final DeviceState getState(final Device device, final Class<? extends DeviceState> clazz); @Override final List<DeviceState> getStates(final Device device); @Override final void updateState(final DeviceState state); @Override final boolean deleteState(final Device device, final Class<? extends DeviceState> clazz);  }### Answer:
@Test(expectedExceptions = NullPointerException.class) public void testGetNull() { stateManager.getState(null, IMADeviceState.class); }
@Test public void testGetUnknown() { final TPMDeviceState savedState = (TPMDeviceState) stateManager.getState(device, TPMDeviceState.class); Assert.assertNull(savedState); }