ConversionParameters { private ConversionParameters() { } private  ConversionParameters(); static Object readParameter(String format, Properties parameters, Parameter configuredParameter, ParameterDefaultValueConfig defaultValueConfig); static Object readParameter(String format, Properties paramaters, Parameter configuredParameter); static boolean readBooleanParameter(String format, Properties parameters, Parameter configuredParameter, ParameterDefaultValueConfig defaultValueConfig); static boolean readBooleanParameter(String format, Properties parameters, Parameter configuredParameter); static String readStringParameter(String format, Properties parameters, Parameter configuredParameter, ParameterDefaultValueConfig defaultValueConfig); static String readStringParameter(String format, Properties parameters, Parameter configuredParameter); static List<String> readStringListParameter(String format, Properties parameters, Parameter configuredParameter, ParameterDefaultValueConfig defaultValueConfig); static List<String> readStringListParameter(String format, Properties parameters, Parameter configuredParameter); static double readDoubleParameter(String format, Properties parameters, Parameter configuredParameter, ParameterDefaultValueConfig defaultValueConfig); static double readDoubleParameter(String format, Properties parameters, Parameter configuredParameter);  }
@Test public void testConversionParameters() { Properties properties = new Properties(); properties.put("test-param-boolean", "true"); Parameter paramBoolean = new Parameter("test-param-boolean", ParameterType.BOOLEAN, "", Boolean.FALSE); Parameter paramBoolean2 = new Parameter("test-param-boolean2", ParameterType.BOOLEAN, "", Boolean.FALSE); assertTrue(ConversionParameters.readBooleanParameter("TEST", properties, paramBoolean)); assertTrue(ConversionParameters.readBooleanParameter("TEST", properties, paramBoolean, ParameterDefaultValueConfig.INSTANCE)); assertFalse(ConversionParameters.readBooleanParameter("TEST", properties, paramBoolean2, ParameterDefaultValueConfig.INSTANCE)); properties.put("test-param-string", "TestProperty"); Parameter paramString = new Parameter("test-param-string", ParameterType.STRING, "", "TestParam"); Parameter paramString2 = new Parameter("test-param-string2", ParameterType.STRING, "", "TestParam"); assertEquals("TestProperty", ConversionParameters.readStringParameter("TEST", properties, paramString)); assertEquals("TestProperty", ConversionParameters.readStringParameter("TEST", properties, paramString, ParameterDefaultValueConfig.INSTANCE)); assertEquals("TestParam", ConversionParameters.readStringParameter("TEST", properties, paramString2, ParameterDefaultValueConfig.INSTANCE)); List<String> stringList = new ArrayList<>(); stringList.add("Test1Property"); stringList.add("Test2Property"); List<String> stringList2 = new ArrayList<>(); stringList2.add("Test1Param"); stringList2.add("Test2Param"); properties.put("test-param-string-list", stringList); Parameter paramStringList = new Parameter("test-param-string-list", ParameterType.STRING_LIST, "", stringList2); Parameter paramStringList2 = new Parameter("test-param-string-list2", ParameterType.STRING_LIST, "", stringList2); assertEquals("Test2Property", ConversionParameters.readStringListParameter("TEST", properties, paramStringList).get(1)); assertEquals("Test2Property", ConversionParameters.readStringListParameter("TEST", properties, paramStringList, ParameterDefaultValueConfig.INSTANCE).get(1)); assertEquals("Test1Param", ConversionParameters.readStringListParameter("TEST", properties, paramStringList2, ParameterDefaultValueConfig.INSTANCE).get(0)); properties.put("test-param-double", 0.06); Parameter paramDouble = new Parameter("test-param-double", ParameterType.DOUBLE, "", 0.08); Parameter paramDouble2 = new Parameter("test-param-double2", ParameterType.DOUBLE, "", 0.08); assertEquals(0.06, ConversionParameters.readDoubleParameter("TEST", properties, paramDouble), 1e-8); assertEquals(0.06, ConversionParameters.readDoubleParameter("TEST", properties, paramDouble, ParameterDefaultValueConfig.INSTANCE), 1e-8); assertEquals(0.08, ConversionParameters.readDoubleParameter("TEST", properties, paramDouble2, ParameterDefaultValueConfig.INSTANCE), 1e-8); InMemoryPlatformConfig config = new InMemoryPlatformConfig(fileSystem); config.createModuleConfig("import-export-parameters-default-value").setStringProperty("test-param-double", "0.06"); assertEquals(0.06, ConversionParameters.readDoubleParameter("TEST", new Properties(), paramDouble, new ParameterDefaultValueConfig(config)), 1e-8); }