### Question:
AppPMMLUtils { public static DataDictionary buildDataDictionary( InputSchema schema, CategoricalValueEncodings categoricalValueEncodings) { List<String> featureNames = schema.getFeatureNames(); List<DataField> dataFields = new ArrayList<>(); for (int featureIndex = 0; featureIndex < featureNames.size(); featureIndex++) { String featureName = featureNames.get(featureIndex); OpType opType; DataType dataType; if (schema.isNumeric(featureName)) { opType = OpType.CONTINUOUS; dataType = DataType.DOUBLE; } else if (schema.isCategorical(featureName)) { opType = OpType.CATEGORICAL; dataType = DataType.STRING; } else { opType = null; dataType = null; } DataField field = new DataField(FieldName.create(featureName), opType, dataType); if (schema.isCategorical(featureName)) { Objects.requireNonNull(categoricalValueEncodings); categoricalValueEncodings.getEncodingValueMap(featureIndex).entrySet().stream(). sorted(Comparator.comparing(Map.Entry::getKey)). map(Map.Entry::getValue). forEach(value -> field.addValues(new Value(value))); } dataFields.add(field); } return new DataDictionary(dataFields).setNumberOfFields(dataFields.size()); } private  AppPMMLUtils(); static String getExtensionValue(PMML pmml, String name); static List<String> getExtensionContent(PMML pmml, String name); static void addExtension(PMML pmml, String key, Object value); static void addExtensionContent(PMML pmml, String key, Collection<?> content); static Array toArray(double... values); static MiningSchema buildMiningSchema(InputSchema schema); static MiningSchema buildMiningSchema(InputSchema schema, double[] importances); static List<String> getFeatureNames(MiningSchema miningSchema); static Integer findTargetIndex(MiningSchema miningSchema); static DataDictionary buildDataDictionary(
      InputSchema schema,
      CategoricalValueEncodings categoricalValueEncodings); static List<String> getFeatureNames(DataDictionary dictionary); static CategoricalValueEncodings buildCategoricalValueEncodings(
      DataDictionary dictionary); static PMML readPMMLFromUpdateKeyMessage(String key,
                                                  String message,
                                                  Configuration hadoopConf);  }### Answer:
@Test public void testBuildDataDictionary() { Map<Integer,Collection<String>> distinctValues = new HashMap<>(); distinctValues.put(1, Arrays.asList("one", "two", "three", "four", "five")); CategoricalValueEncodings categoricalValueEncodings = new CategoricalValueEncodings(distinctValues); DataDictionary dictionary = AppPMMLUtils.buildDataDictionary(buildTestSchema(), categoricalValueEncodings); assertEquals(4, dictionary.getNumberOfFields().intValue()); checkDataField(dictionary.getDataFields().get(0), "foo", null); checkDataField(dictionary.getDataFields().get(1), "bar", true); checkDataField(dictionary.getDataFields().get(2), "baz", null); checkDataField(dictionary.getDataFields().get(3), "bing", false); List<Value> dfValues = dictionary.getDataFields().get(1).getValues(); assertEquals(5, dfValues.size()); String[] categoricalValues = { "one", "two", "three", "four", "five" }; for (int i = 0; i < categoricalValues.length; i++) { assertEquals(categoricalValues[i], dfValues.get(i).getValue()); } }