@Test
public void testUpdateViewInstance_invalid() throws Exception {
ViewDAO viewDAO = createNiceMock(ViewDAO.class);
ViewInstanceDAO viewInstanceDAO = createNiceMock(ViewInstanceDAO.class);
ViewRegistry.init(viewDAO, viewInstanceDAO);
ViewRegistry registry = ViewRegistry.getInstance();
Properties properties = new Properties();
properties.put("p1", "v1");
Configuration ambariConfig = new Configuration(properties);
ViewConfig config = ViewConfigTest.getConfig(xml_valid_instance);
ViewConfig invalidConfig = ViewConfigTest.getConfig(xml_invalid_instance);
ViewEntity viewEntity = getViewEntity(config, ambariConfig, getClass().getClassLoader(), "");
ViewInstanceEntity viewInstanceEntity = getViewInstanceEntity(viewEntity, config.getInstances().get(0));
ViewInstanceEntity updateInstance = getViewInstanceEntity(viewEntity, invalidConfig.getInstances().get(0));
expect(viewInstanceDAO.merge(viewInstanceEntity)).andReturn(null);
expect(viewInstanceDAO.findByName("MY_VIEW{1.0.0}", viewInstanceEntity.getInstanceName())).andReturn(viewInstanceEntity);
replay(viewDAO, viewInstanceDAO);
registry.addDefinition(viewEntity);
registry.installViewInstance(viewInstanceEntity);