### Question:
RefreshTreeCellRenderer implements ButtonStateUpdater { @Override public void update(QuadStateIconButton button, TreeTableTreeNode node) { boolean visible = false; if (node.getPayload() != null && node.getPayload().getPayloadData() instanceof GroupByNodeUserObject) { GroupByNodeUserObject uo = (GroupByNodeUserObject)node.getPayload().getPayloadData(); DataGroupInfo dgi = uo.getDataGroupInfo(); visible = dgi instanceof RefreshableDataGroupInfo; } button.setHidden(!visible); }  @Override void update(QuadStateIconButton button, TreeTableTreeNode node);  }### Answer:
@Test public void testUpdate() { GroupByNodeUserObject payload = new GroupByNodeUserObject(new RefreshableGroupMock()); ButtonModelPayload buttonPayload = new ButtonModelPayload(payload, "", ""); TreeTableTreeNode node = new TreeTableTreeNode(null, buttonPayload); RefreshTreeCellRenderer renderer = new RefreshTreeCellRenderer(); QuadStateIconButton button = new QuadStateIconButton((ImageIcon)null, (ImageIcon)null, (ImageIcon)null, (ImageIcon)null); renderer.update(button, node); assertFalse(button.isHidden()); }
@Test public void testUpdateNonRefreshableGroup() { GroupByNodeUserObject payload = new GroupByNodeUserObject((DataGroupInfo)EasyMock.createMock(DataGroupInfo.class)); ButtonModelPayload buttonPayload = new ButtonModelPayload(payload, "", ""); TreeTableTreeNode node = new TreeTableTreeNode(null, buttonPayload); RefreshTreeCellRenderer renderer = new RefreshTreeCellRenderer(); QuadStateIconButton button = new QuadStateIconButton((ImageIcon)null, (ImageIcon)null, (ImageIcon)null, (ImageIcon)null); renderer.update(button, node); assertTrue(button.isHidden()); }
@Test public void testUpdateNoPayload() { ButtonModelPayload buttonPayload = new ButtonModelPayload(null, "", ""); TreeTableTreeNode node = new TreeTableTreeNode(null, buttonPayload); RefreshTreeCellRenderer renderer = new RefreshTreeCellRenderer(); QuadStateIconButton button = new QuadStateIconButton((ImageIcon)null, (ImageIcon)null, (ImageIcon)null, (ImageIcon)null); renderer.update(button, node); assertTrue(button.isHidden()); }
@Test public void testUpdateNullGroup() { GroupByNodeUserObject payload = new GroupByNodeUserObject("label"); ButtonModelPayload buttonPayload = new ButtonModelPayload(payload, "", ""); TreeTableTreeNode node = new TreeTableTreeNode(null, buttonPayload); RefreshTreeCellRenderer renderer = new RefreshTreeCellRenderer(); QuadStateIconButton button = new QuadStateIconButton((ImageIcon)null, (ImageIcon)null, (ImageIcon)null, (ImageIcon)null); renderer.update(button, node); assertTrue(button.isHidden()); }
@Test public void testUpdatePayloadNull() { TreeTableTreeNode node = new TreeTableTreeNode(null, null); RefreshTreeCellRenderer renderer = new RefreshTreeCellRenderer(); QuadStateIconButton button = new QuadStateIconButton((ImageIcon)null, (ImageIcon)null, (ImageIcon)null, (ImageIcon)null); renderer.update(button, node); assertTrue(button.isHidden()); }