### Question:
DBTPMDeviceStateManager extends DBDeviceStateManager implements TPMDeviceStateManager { @Override public final TPMDeviceState saveState(final TPMDeviceState state) throws TPMDeviceStateManagerException { try { return (TPMDeviceState) super.saveState(state); } catch (DeviceStateManagerException e) { throw new TPMDeviceStateManagerException(e); } } DBTPMDeviceStateManager(final SessionFactory factory); @Override final TPMDeviceState saveState(final TPMDeviceState state); @Override final TPMDeviceState getState(final Device device); @Override final void updateState(final TPMDeviceState state); @Override final boolean deleteState(final Device device);  }### Answer:
@Test public void testSaveDefaultState() { Assert.assertEquals(DBUtility.getCount(sessionFactory, TPMDeviceState.class), 0); final TPMDeviceState state = new TPMDeviceState(device); final TPMDeviceState savedState = stateManager.saveState(state); Assert.assertEquals(DBUtility.getCount(sessionFactory, TPMDeviceState.class), 1); Assert.assertEquals(savedState, state); }
@Test(expectedExceptions = TPMDeviceStateManagerException.class) public void testSaveWithSameDevice() { final TPMDeviceState state = new TPMDeviceState(device); final TPMDeviceState state2 = new TPMDeviceState(device); stateManager.saveState(state); stateManager.saveState(state2); }
@Test(expectedExceptions = NullPointerException.class) public void testSaveNullState() { stateManager.saveState(null); }