ComponentPropertyReader { public static Integer readInteger(Properties properties, Properties global, final String propertyName, String instanceId, ComponentMetadata componentMetadata) { return readInteger(properties, global, propertyName, instanceId, componentMetadata, null); } private  ComponentPropertyReader(); static String readString(Properties properties, Properties global,
                                    final String propertyName, String instanceId, ComponentMetadata componentMetadata); static String readString(Properties properties, Properties global,
                                    final String propertyName, String instanceId,
                                    ComponentMetadata componentMetadata, String defaultValue); static Integer readInteger(Properties properties, Properties global, final String propertyName,
            String instanceId, ComponentMetadata componentMetadata); static Integer readInteger(Properties properties, Properties global,
                                      final String propertyName, String instanceId,
                                      ComponentMetadata componentMetadata, Integer defaultValue); static Long readLong(Properties properties, Properties global,
                                final String propertyName, String instanceId, ComponentMetadata componentMetadata); static Long readLong(Properties properties, Properties global,
                                final String propertyName, String instanceId,
                                ComponentMetadata componentMetadata, Long defaultValue); static Boolean readBoolean(Properties properties, Properties global, final String propertyName,
            String instanceId, ComponentMetadata componentMetadata); static Boolean readBoolean(Properties properties, Properties global,
                                      final String propertyName, String instanceId,
                                      ComponentMetadata componentMetadata, Boolean defaultValue);  }
@Test public void testReadInteger() throws Exception { Properties properties = new Properties(); properties.setProperty("source.source_1.zookeeper", "10000"); Properties globalProperties = new Properties(); final int connStr = ComponentPropertyReader.readInteger(properties, globalProperties, "zookeeper", "source_1", ComponentMetadata.builder() .namespace("global") .name("source") .id("1234") .type(ComponentType.SOURCE) .build()); assertEquals(10000, connStr); }
@Test public void testReadIntegerFromGlobal() { Properties properties = new Properties(); Properties globalProperties = new Properties(); globalProperties.setProperty("source.source_1.brokers", "localhost:9092"); globalProperties.setProperty("source.source_1.topic-name", "x"); globalProperties.setProperty("processor.processor_1.queueSize", "100"); globalProperties.setProperty("source.source_1.zookeeper", "localhost:2181"); final int connStr = ComponentPropertyReader.readInteger(properties, globalProperties, "queueSize", "processor_1", ComponentMetadata.builder() .namespace("global") .name("source") .id("1234") .type(ComponentType.PROCESSOR) .build()); assertEquals(100, connStr); }