@Test
public void testInstallViewInstance() throws Exception {

  ViewRegistry registry = ViewRegistry.getInstance();
  Properties properties = new Properties();
  properties.put("p1", "v1");
  Configuration ambariConfig = new Configuration(properties);
  ViewConfig config = ViewConfigTest.getConfig(XML_VALID_INSTANCE);
  ViewEntity viewEntity = getViewEntity(config, ambariConfig, getClass().getClassLoader(), "");
  ViewInstanceEntity viewInstanceEntity = getViewInstanceEntity(viewEntity, config.getInstances().get(0));
  expect(viewInstanceDAO.merge(viewInstanceEntity)).andReturn(viewInstanceEntity);
  handlerList.addViewInstance(viewInstanceEntity);
  replay(viewDAO, viewInstanceDAO, resourceTypeDAO, securityHelper, handlerList);
  registry.addDefinition(viewEntity);
  registry.installViewInstance(viewInstanceEntity);
  Collection<ViewInstanceEntity> viewInstanceDefinitions = registry.getInstanceDefinitions(viewEntity);
  Assert.assertEquals(1, viewInstanceDefinitions.size());
  ViewInstanceEntity instanceEntity = viewInstanceDefinitions.iterator().next();
  Assert.assertEquals("v2-1", instanceEntity.getProperty("p2").getValue() );
  Assert.assertEquals(viewInstanceEntity, viewInstanceDefinitions.iterator().next());
  Assert.assertEquals("MY_VIEW{1.0.0}", viewInstanceEntity.getResource().getResourceType().getName());
  verify(viewDAO, viewInstanceDAO, resourceTypeDAO, securityHelper, handlerList);
}