ColumnUtilities extends ColumnUtilitiesBase { public String[] getValueList(final BaseColumn col) { if (col instanceof AttributeCol52) { return getValueList((AttributeCol52) col); } else if (col instanceof ConditionCol52) { return getValueList((ConditionCol52) col); } else if (col instanceof ActionSetFieldCol52) { return getValueList((ActionSetFieldCol52) col); } else if (col instanceof ActionInsertFactCol52) { return getValueList((ActionInsertFactCol52) col); } return new String[0]; } ColumnUtilities(final GuidedDecisionTable52 model,
                           final AsyncPackageDataModelOracle oracle); static void setColumnLabelStyleWhenHidden(final ColumnLabelWidget label,
                                                     final boolean isHidden); static boolean canAcceptOtherwiseValues(final BaseColumn column); String[] getValueList(final BaseColumn col); boolean hasValueList(final AttributeCol52 col);  }
@Test public void testGetValueConditionColumn() throws Exception { column.setFactField(FIELD_NAME); column.setFieldType(DataType.TYPE_NUMERIC_INTEGER); column.setValueList("a,1,1.1, ,-1, 123,456 , -789 "); final String[] valueList = utilities.getValueList(column); Assertions.assertThat(valueList).containsExactly("1", "-1", "123", "456", "-789"); }
@Test public void testIntegerAliases() { column.setFactField(FIELD_NAME); column.setFieldType(DataType.TYPE_NUMERIC_INTEGER); column.setValueList("1=One,2=Two"); final String[] valueList = utilities.getValueList(column); Assertions.assertThat(valueList).containsExactly("1=One", "2=Two"); }
@Test public void testBooleanAliases() { column.setFactField(FIELD_NAME); column.setFieldType(DataType.TYPE_BOOLEAN); column.setValueList("true=Yes,false=No"); final String[] valueList = utilities.getValueList(column); Assertions.assertThat(valueList).containsExactly("true=Yes", "false=No"); }
@Test public void testBooleanAliasesInvalidValues() { column.setFactField(FIELD_NAME); column.setFieldType(DataType.TYPE_BOOLEAN); column.setValueList("yes=Yes, no=No"); Assertions.assertThat(utilities.getValueList(column)).isEmpty(); }
@Test public void testGetValueSetFieldColumn() throws Exception { pattern.setFactType(FACT_TYPE); pattern.setBoundName("$a"); when(model.getConditions()).thenReturn(Arrays.asList(pattern)); final ActionSetFieldCol52 column = new ActionSetFieldCol52(); column.setFactField(FIELD_NAME); column.setBoundName("$a"); column.setValueList("a,1,1.1, ,-1, 123,456 , -789 "); when(oracle.getFieldType(FACT_TYPE, FIELD_NAME)).thenReturn("Integer"); final String[] valueList = utilities.getValueList(column); Assertions.assertThat(valueList).containsExactly("1", "-1", "123", "456", "-789"); }
@Test public void testGetValueInsertFactColumn() throws Exception { final ActionInsertFactCol52 column = new ActionInsertFactCol52(); column.setFactField(FIELD_NAME); column.setFactType(FACT_TYPE); column.setValueList("a,1,1.1, ,-1, 123,456 , -789 "); when(oracle.getFieldType(FACT_TYPE, FIELD_NAME)).thenReturn(DataType.TYPE_NUMERIC_INTEGER); final String[] valueList = utilities.getValueList(column); Assertions.assertThat(valueList).containsExactly("1", "-1", "123", "456", "-789"); }