### Question:
StringTableCellRenderer implements TableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); @SuppressWarnings("unchecked") E val = (E) value; label.setText(representer.apply(val)); return label; } StringTableCellRenderer(Function<E, String> representer); @Override Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                                                 boolean hasFocus, int row, int column);  }### Answer:
@Test public void returnsNullForNullValue() { Component result = renderer.getTableCellRendererComponent(null, null, false, false, 0, 0); assertThat(result, is(instanceOf(JLabel.class))); JLabel labelResult = (JLabel) result; assertThat(labelResult.getText(), is(equalTo(""))); }
@Test public void returnsLabelWithNameAsText() { Vehicle vehicle = new Vehicle("VehicleName"); TCSObjectReference<Vehicle> vehicleReference = vehicle.getReference(); Component result = renderer.getTableCellRendererComponent(null, vehicleReference, false, false, 0, 0); assertThat(result, is(instanceOf(JLabel.class))); JLabel labelResult = (JLabel) result; assertThat(labelResult.getText(), is(equalTo("VehicleName"))); }