### Question:
VFSRuntimeRegistry extends InMemoryRuntimeRegistry { @Override public void registerRuntime(final Runtime runtime) { checkNotNull("runtime", runtime); final Path path = buildRuntimePath(runtime.getId()); try { registryHelper.storeEntry(path, runtime); } catch (Exception e) { logger.error("Unexpected error was produced during runtime marshalling/storing, runtime: " + runtime, e); throw new RuntimeException("Unexpected error was produced during runtime marshalling/storing, runtime: " + runtime, e); } super.registerRuntime(runtime); } VFSRuntimeRegistry(); @Inject  VFSRuntimeRegistry(final VFSRegistryHelper registryHelper); @Override void registerProvider(final Provider provider); @Override void deregisterProvider(final Provider provider); @Override void deregisterProvider(final String providerId); @Override void registerRuntime(final Runtime runtime); @Override void deregisterRuntime(final RuntimeId runtimeId);  }### Answer:
@Test @Override public void testRegisterRuntime() { prepareRuntimeTargetPath(); runtimeRegistry.registerRuntime(runtime); try { verify(registryHelper, times(1)).storeEntry(runtimeTargetPath, runtime); } catch (Exception e) { fail(e.getMessage()); } verifyRuntimeIsRegistered(runtime); }
@Test public void testRegisterRuntimeWhenMarshallingErrors() throws Exception { prepareRuntimeTargetPath(); expectedException.expectMessage("Unexpected error was produced during runtime marshalling/storing, runtime: " + runtime); doThrow(new Exception("no matter the message here")) .when(registryHelper) .storeEntry(runtimeTargetPath, runtime); runtimeRegistry.registerRuntime(runtime); }