### Question:
PopupDropDownEditCell extends
                                   AbstractPopupEditCell<String, String> { @Override public void render(Context context, String value, SafeHtmlBuilder sb) { DropDownData dd = dmo.getEnums(this.factType, this.factField, this.dropDownManager.getCurrentValueMap(context)); if (dd == null) { return; } utilities.setDropDownData(value, dd, isMultipleSelect, dmo.getResourcePath(), listBox); if (value != null) { String label = getLabel(value); sb.append(renderer.render(label)); } } PopupDropDownEditCell(final String factType,
                                 final String factField,
                                 final AsyncPackageDataModelOracle dmo,
                                 final CellTableDropDownDataValueMapProvider dropDownManager,
                                 final boolean isReadOnly);  PopupDropDownEditCell(final String factType,
                                 final String factField,
                                 final AsyncPackageDataModelOracle dmo,
                                 final CellTableDropDownDataValueMapProvider dropDownManager,
                                 final boolean isMultipleSelect,
                                 final boolean isReadOnly); @Override void render(Context context,
                       String value,
                       SafeHtmlBuilder sb);  }### Answer:
@Test public void testRender_NoDropDownData() { final Cell.Context context = mock(Cell.Context.class); final SafeHtmlBuilder safeHtmlBuilder = mock(SafeHtmlBuilder.class); cell.render(context, "content", safeHtmlBuilder); verify(safeHtmlBuilder, never()).append(any(SafeHtml.class)); }
@Test public void testRender_SimpleDropDownData() { final Cell.Context context = mock(Cell.Context.class); final SafeHtmlBuilder safeHtmlBuilder = mock(SafeHtmlBuilder.class); final String[] data = new String[]{"one", "two"}; final DropDownData dd = DropDownData.create(data); when(dmo.getEnums(eq(FACT_TYPE), eq(FACT_FIELD), any(Map.class))).thenReturn(dd); when(listBox.getItemCount()).thenReturn(data.length); when(listBox.getValue(eq(0))).thenReturn("one"); when(listBox.getValue(eq(1))).thenReturn("two"); when(listBox.getItemText(eq(0))).thenReturn("one"); when(listBox.getItemText(eq(1))).thenReturn("two"); cell.render(context, "one", safeHtmlBuilder); final ArgumentCaptor<SafeHtml> captor = ArgumentCaptor.forClass(SafeHtml.class); verify(safeHtmlBuilder, times(1)).append(captor.capture()); assertEquals("one", captor.getValue().asString()); }
@Test public void testRender_LookupDropDownData() { final Cell.Context context = mock(Cell.Context.class); final SafeHtmlBuilder safeHtmlBuilder = mock(SafeHtmlBuilder.class); final String[] data = new String[]{"1=one", "2=two"}; final DropDownData dd = DropDownData.create(data); when(dmo.getEnums(eq(FACT_TYPE), eq(FACT_FIELD), any(Map.class))).thenReturn(dd); when(listBox.getItemCount()).thenReturn(data.length); when(listBox.getValue(eq(0))).thenReturn("1"); when(listBox.getValue(eq(1))).thenReturn("2"); when(listBox.getItemText(eq(0))).thenReturn("one"); when(listBox.getItemText(eq(1))).thenReturn("two"); cell.render(context, "1", safeHtmlBuilder); final ArgumentCaptor<SafeHtml> captor = ArgumentCaptor.forClass(SafeHtml.class); verify(safeHtmlBuilder, times(1)).append(captor.capture()); assertEquals("one", captor.getValue().asString()); }