JsonContentFilter implements DirectResponseOperator { public void initialize(Properties properties) throws RequiredInputMissingException, ComponentInitializationFailedException { if(properties == null) throw new RequiredInputMissingException("Missing required properties"); for(int i = 1; i < Integer.MAX_VALUE; i++) { String expression = properties.getProperty(CFG_FIELD_PREFIX + i + ".expression"); if(StringUtils.isBlank(expression)) break; String path = properties.getProperty(CFG_FIELD_PREFIX + i + ".path"); String valueType = properties.getProperty(CFG_FIELD_PREFIX + i + ".type"); try { this.fields.add(new JsonContentFilterFieldSetting(path.split("\\."), Pattern.compile(expression), StringUtils.equalsIgnoreCase("STRING", valueType) ? JsonContentType.STRING : JsonContentType.NUMERICAL)); } catch(PatternSyntaxException e) { throw new ComponentInitializationFailedException("Failed to parse '"+expression+"' into a valid pattern expression"); } } if(logger.isDebugEnabled()) logger.debug("json content filter [id="+id+"] initialized"); }  void initialize(Properties properties); boolean shutdown(); StreamingDataMessage[] onMessage(StreamingDataMessage message); MicroPipelineComponentType getType(); long getTotalNumOfMessages(); void setId(String id); String getId(); static final String CFG_FIELD_PREFIX; }
@Test public void testInitialize_withNullProperties() throws Exception { try { new JsonContentFilter().initialize(null); Assert.fail("Missing required input"); } catch(RequiredInputMissingException e) { } }