### Question:
VFSRuntimeRegistry extends InMemoryRuntimeRegistry { @Override public void registerProvider(final Provider provider) { checkNotNull("provider", provider); final Path path = buildProviderPath(provider.getId()); try { registryHelper.storeEntry(path, provider); } catch (Exception e) { logger.error("Unexpected error was produced during provider marshalling/storing, provider: " + provider, e); throw new RuntimeException("Unexpected error was produced during provider marshalling/storing, provider: " + provider, e); } super.registerProvider(provider); } 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 testRegisterProvider() { prepareProviderTargetPath(); runtimeRegistry.registerProvider(provider); try { verify(registryHelper, times(1)).storeEntry(providerTargetPath, provider); } catch (Exception e) { fail(e.getMessage()); } verifyProviderIsRegistered(provider); }
@Test public void testRegisterProviderWhenMarshallingErrors() throws Exception { prepareProviderTargetPath(); expectedException.expectMessage("Unexpected error was produced during provider marshalling/storing, provider: " + provider); doThrow(new Exception("no matter the message here")) .when(registryHelper) .storeEntry(providerTargetPath, provider); runtimeRegistry.registerProvider(provider); }