EmbeddedSensorHandle implements ISensorHandle { @Override public void shutdown() throws SensorShutdownException { try { chainStorage.rollback(chainId, chainModificationId); } catch (ChainModificationException | ChainNotFoundException e) { throw new SensorShutdownException(e); } } EmbeddedSensorHandle(final IChainStorage chainStorage, final Object chainId, final Object chainModificationId); @Override void shutdown();  }
@Test public void Should_rollbackTargetChainModification() throws Exception { new EmbeddedSensorHandle(chainStorageMock, chainId, modId).shutdown(); verify(chainStorageMock).rollback(chainId, modId); }
@Test(expected = SensorShutdownException.class) public void Should_wrapExceptionThrownByRollbackMethod() throws Exception { doThrow(ChainModificationException.class).when(chainStorageMock).rollback(chainId, modId); new EmbeddedSensorHandle(chainStorageMock, chainId, modId).shutdown(); }