public static Set<ViewInstanceEntity> getViewInstanceEntities(ViewEntity viewDefinition) throws Exception { Set<ViewInstanceEntity> entities = new HashSet<ViewInstanceEntity>(); InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0); entities.add(new ViewInstanceEntity(viewDefinition, instanceConfig)); instanceConfig = InstanceConfigTest.getInstanceConfigs().get(1); entities.add(new ViewInstanceEntity(viewDefinition, instanceConfig)); return entities; }
@Test public void testGetDescription() throws Exception { InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_with_instance_label).get(0); ViewEntity viewDefinition = ViewEntityTest.getViewEntity(); ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); Assert.assertEquals( "This is an instance description.", viewInstanceDefinition.getDescription()); instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_without_instance_label).get(0); viewDefinition = ViewEntityTest.getViewEntity(); viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); Assert.assertNull(viewInstanceDefinition.getDescription()); }
@Test public void testGetIcon64() throws Exception { InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_with_instance_label).get(0); ViewEntity viewDefinition = ViewEntityTest.getViewEntity(); ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); Assert.assertEquals( "/this/is/the/icon/url/instance_1_icon64.png", viewInstanceDefinition.getIcon64()); viewInstanceDefinition.setIcon64("/a/different/icon.png"); Assert.assertEquals("/a/different/icon.png", viewInstanceDefinition.getIcon64()); instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_with_instance_label).get(1); viewDefinition = ViewEntityTest.getViewEntity(); viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); Assert.assertEquals("/this/is/the/icon/url/icon64.png", viewInstanceDefinition.getIcon64()); }
@Test public void testGetConfiguration() throws Exception { InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0); ViewEntity viewDefinition = ViewEntityTest.getViewEntity(); ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); Assert.assertEquals(instanceConfig, viewInstanceDefinition.getConfiguration()); }
@Test public void testGetLabel() throws Exception { // with an instance label InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_with_instance_label).get(0); ViewEntity viewDefinition = ViewEntityTest.getViewEntity(); ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); Assert.assertEquals("My Instance 1!", viewInstanceDefinition.getLabel()); // without an instance label instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_without_instance_label).get(0); viewDefinition = ViewEntityTest.getViewEntity(); viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); // should default to view label Assert.assertEquals("My View!", viewInstanceDefinition.getLabel()); }
@Test public void testIsVisible() throws Exception { InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_with_instance_label).get(0); ViewEntity viewDefinition = ViewEntityTest.getViewEntity(); ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); Assert.assertTrue(viewInstanceDefinition.isVisible()); instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_with_instance_label).get(1); viewDefinition = ViewEntityTest.getViewEntity(); viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); Assert.assertFalse(viewInstanceDefinition.isVisible()); instanceConfig = InstanceConfigTest.getInstanceConfigs(xml_without_instance_label).get(0); viewDefinition = ViewEntityTest.getViewEntity(); viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig); Assert.assertTrue(viewInstanceDefinition.isVisible()); }
public static ViewInstanceEntity getViewInstanceEntity() throws Exception { InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0); ViewEntity viewDefinition = ViewEntityTest.getViewEntity(); ViewInstanceEntity viewInstanceEntity = new ViewInstanceEntity(viewDefinition, instanceConfig); ResourceTypeEntity resourceTypeEntity = new ResourceTypeEntity(); resourceTypeEntity.setId(10); resourceTypeEntity.setName(viewDefinition.getName()); viewDefinition.setResourceType(resourceTypeEntity); ResourceEntity resourceEntity = new ResourceEntity(); resourceEntity.setId(20L); resourceEntity.setResourceType(resourceTypeEntity); viewInstanceEntity.setResource(resourceEntity); return viewInstanceEntity; }