@Test
public void testAddInstanceDefinition() throws Exception {

  ViewRegistry registry = ViewRegistry.getInstance();
  ViewEntity viewEntity = ViewEntityTest.getViewEntity();
  InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0);
  ViewInstanceEntity viewInstanceEntity = new ViewInstanceEntity(viewEntity, instanceConfig);
  ResourceTypeEntity resourceTypeEntity = new ResourceTypeEntity();
  resourceTypeEntity.setId(10);
  resourceTypeEntity.setName(viewEntity.getName());
  viewEntity.setResourceType(resourceTypeEntity);
  ResourceEntity resourceEntity = new ResourceEntity();
  resourceEntity.setId(20L);
  resourceEntity.setResourceType(resourceTypeEntity);
  viewInstanceEntity.setResource(resourceEntity);
  registry.addDefinition(viewEntity);
  registry.addInstanceDefinition(viewEntity, viewInstanceEntity);
  Collection<ViewInstanceEntity> viewInstanceDefinitions = registry.getInstanceDefinitions(viewEntity);
  Assert.assertEquals(1, viewInstanceDefinitions.size());
  Assert.assertEquals(viewInstanceEntity, viewInstanceDefinitions.iterator().next());
}