@Test public void addContainerPropertyNull() { try { ContainerUtils.addContainerProperty(null, null, null, null); fail("It should throw a NullPointerException"); } catch (NullPointerException e) { assertTrue("Should throw an NullPointerException", e instanceof NullPointerException); } try { ContainerUtils.addContainerProperty(null, "propertyName", String.class, null); fail("It should throw a NullPointerException"); } catch (NullPointerException e) { assertTrue("Should throw an NullPointerException", e instanceof NullPointerException); } try { ContainerUtils.addContainerProperty(new IndexedContainer(), null, null, null); fail("It should throw a NullPointerException"); } catch (NullPointerException e) { assertTrue("Should throw an NullPointerException", e instanceof NullPointerException); } try { ContainerUtils.addContainerProperty(new IndexedContainer(), "nullProperty", null, null); fail("It should throw a NullPointerException"); } catch (NullPointerException e) { assertTrue("Should throw an NullPointerException", e instanceof NullPointerException); } }
@Test public void addContainerPropertyMetadata() { Container container = new IndexedContainer(); PropertyMetadata metadata = new PropertyMetadata("propertyName", String.class, null, "propertyName"); ContainerUtils.addContainerProperty(container, metadata); assertTrue( "container should contains a property 'propertyName'", container.getContainerPropertyIds().contains(metadata.getPropertyName())); assertEquals(String.class, container.getType("propertyName")); }