final ViewRegistry viewRegistry = mock(ViewRegistry.class);
// A changed (and persisted) configuration created by an admin
final ViewConfig config = mock(ViewConfig.class);
final ViewFactory factory = factorySource.getFactory(config.getFactoryName());
final View newView = factory.createView(config);
// De-register the existing view
final View existingView = viewRegistry.findViewByName(config.getViewName());
if (existingView != null) {
viewRegistry.unregisterView(existingView);