DTCellValueWidgetFactory { public Widget getWidget(Pattern52 pattern, ConditionCol52 column, DTCellValue52 value) { final boolean isMultipleSelect = isExplicitListOperator(column.getOperator()); if (columnUtilities.hasValueList(column)) { final String[] valueList = columnUtilities.getValueList(column); return makeListBoxForColumn(DropDownData.create(valueList), pattern, column, value, isMultipleSelect); } else if (oracle.hasEnums(pattern.getFactType(), column.getFactField())) { return makeHasEnumsListBox(pattern, column, value, isMultipleSelect, column.getFactField(), pattern.getFactType()); } DataType.DataTypes type = columnUtilities.getTypeSafeType(pattern, column); return makeHasNoValuesAndEnumsWidget(type, value); } private  DTCellValueWidgetFactory(GuidedDecisionTable52 model,
                                     AsyncPackageDataModelOracle oracle,
                                     LimitedEntryDropDownManager dropDownManager,
                                     boolean isReadOnly,
                                     boolean allowEmptyValues); static DTCellValueWidgetFactory getInstance(GuidedDecisionTable52 model,
                                                       AsyncPackageDataModelOracle oracle,
                                                       boolean isReadOnly,
                                                       boolean allowEmptyValues); DTCellValue52 makeNewValue(DTColumnConfig52 c); DTCellValue52 makeNewValue(Pattern52 p,
                                      ConditionCol52 c); Widget getWidget(Pattern52 pattern,
                            ConditionCol52 column,
                            DTCellValue52 value); DTCellValue52 makeNewValue(Pattern52 p,
                                      ActionSetFieldCol52 c); Widget getWidget(Pattern52 pattern,
                            ActionSetFieldCol52 column,
                            DTCellValue52 value); Widget getWidget(ActionInsertFactCol52 column,
                            DTCellValue52 value); IsWidget getWidget(BRLVariableColumn column,
                              DTCellValue52 value);  }
@Test public void testGetWidgetValueList() throws Exception { insertFactCol52.setValueList("a,b,c"); Widget widget = factory.getWidget(insertFactCol52, cellValue); assertTrue(widget instanceof ListBox); }
@Test public void testGetWidgetEnums() throws Exception { insertFactCol52.setFactType("Person"); insertFactCol52.setFactField("name"); when(oracle.hasEnums("Person", "name")).thenReturn(true); Widget widget = factory.getWidget(insertFactCol52, cellValue); assertTrue(widget instanceof ListBox); }
@Test public void testGetWidgetEnumsForBRLColumn() throws Exception { BRLActionVariableColumn column = mock(BRLActionVariableColumn.class); doReturn("Person").when(column).getFactType(); doReturn("name").when(column).getFactField(); when(oracle.hasEnums("Person", "name")).thenReturn(true); IsWidget widget = factory.getWidget(column, cellValue); assertTrue(widget instanceof ListBox); }
@Test public void testGeTextBoxForBRLColumn() throws Exception { BRLActionVariableColumn column = mock(BRLActionVariableColumn.class); doReturn("Person").when(column).getFactType(); doReturn("name").when(column).getFactField(); when(oracle.hasEnums("Person", "name")).thenReturn(false); IsWidget widget = factory.getWidget(column, cellValue); assertTrue(widget instanceof TextBox); }
@Test public void testEnumDropdownForBRLColumn() throws Exception { BRLConditionVariableColumn column = mock(BRLConditionVariableColumn.class); doReturn("Person").when(column).getFactType(); doReturn("name").when(column).getFactField(); when(oracle.hasEnums("Person", "name")).thenReturn(true); IsWidget widget = factory.getWidget(column, cellValue); assertTrue(widget instanceof ListBox); }