ComponentRenderer extends Grid.AbstractRenderer<Component> implements DataGenerator { @Override public JsonValue encode(Component component) { if (component != null) { addComponentToGrid(component); return Json.create(component.getConnectorId()); } else { return Json.createNull(); } } ComponentRenderer(); @Override JsonValue encode(Component component); @Override void setParent(ClientConnector parent); @Override void generateData(Object itemId, Item item, JsonObject jsonRow); @Override void destroyData(Object itemId);  }
@Test public void encodeNullComponent() { ComponentRenderer renderer = new ComponentRenderer(); assertThat(renderer.encode(null), equalTo((JsonValue) Json.createNull())); }
@Test(expected = IllegalStateException.class) public void encodeComponentWithoutBeingAttached() { ComponentRenderer renderer = new ComponentRenderer(); renderer.encode(new Label("test")); }