@Test(expected = ConfigurationException.class) public void testContextElementWithBadJsonPathInMetadata() throws ConfigurationException { Metadata m = new Metadata("Meta", "string"); m.setJsonpath("$BADJSONPATH2"); Attribute a = new Attribute("Attr", "string"); a.setMetadata(Collections.singleton(m)); EventTypeIn e = new EventTypeIn("S.*", "TempSensor", true); e.setAttributes(Collections.singleton(a)); Configuration configuration = new Configuration(); configuration.setEventTypeIns(Collections.singletonList(e)); eventMapper.setConfiguration(configuration); }
public void setConfiguration(Configuration configuration) throws ConfigurationException { Map<String, JsonPath> jsonpaths = new HashMap<>(); for (EventTypeIn eventTypeIn : configuration.getEventTypeIns()) { for (Attribute attribute : eventTypeIn.getAttributes()) { String jsonpath = attribute.getJsonpath(); if (jsonpath != null) { try { jsonpaths.put(eventTypeIn.getType() + "/" + attribute.getName(), JsonPath.compile(jsonpath)); } catch (IllegalArgumentException|InvalidPathException e) { throw new ConfigurationException("invalid jsonpath expression for attribute "+attribute.getName(), e); } } for (Metadata metadata : attribute.getMetadata()) { jsonpath = metadata.getJsonpath(); if (jsonpath != null) { try { jsonpaths.put(eventTypeIn.getType() + "/" + attribute.getName() + "/" + metadata.getName(), JsonPath.compile(jsonpath)); } catch (IllegalArgumentException|InvalidPathException e) { throw new ConfigurationException("invalid jsonpath expression for metadata "+attribute.getName()+"/"+metadata.getName(), e); } } } } } this.jsonpaths = jsonpaths; }
EventMapper { public void setConfiguration(Configuration configuration) throws ConfigurationException { Map<String, JsonPath> jsonpaths = new HashMap<>(); for (EventTypeIn eventTypeIn : configuration.getEventTypeIns()) { for (Attribute attribute : eventTypeIn.getAttributes()) { String jsonpath = attribute.getJsonpath(); if (jsonpath != null) { try { jsonpaths.put(eventTypeIn.getType() + "/" + attribute.getName(), JsonPath.compile(jsonpath)); } catch (IllegalArgumentException|InvalidPathException e) { throw new ConfigurationException("invalid jsonpath expression for attribute "+attribute.getName(), e); } } for (Metadata metadata : attribute.getMetadata()) { jsonpath = metadata.getJsonpath(); if (jsonpath != null) { try { jsonpaths.put(eventTypeIn.getType() + "/" + attribute.getName() + "/" + metadata.getName(), JsonPath.compile(jsonpath)); } catch (IllegalArgumentException|InvalidPathException e) { throw new ConfigurationException("invalid jsonpath expression for metadata "+attribute.getName()+"/"+metadata.getName(), e); } } } } } this.jsonpaths = jsonpaths; } }
EventMapper { public void setConfiguration(Configuration configuration) throws ConfigurationException { Map<String, JsonPath> jsonpaths = new HashMap<>(); for (EventTypeIn eventTypeIn : configuration.getEventTypeIns()) { for (Attribute attribute : eventTypeIn.getAttributes()) { String jsonpath = attribute.getJsonpath(); if (jsonpath != null) { try { jsonpaths.put(eventTypeIn.getType() + "/" + attribute.getName(), JsonPath.compile(jsonpath)); } catch (IllegalArgumentException|InvalidPathException e) { throw new ConfigurationException("invalid jsonpath expression for attribute "+attribute.getName(), e); } } for (Metadata metadata : attribute.getMetadata()) { jsonpath = metadata.getJsonpath(); if (jsonpath != null) { try { jsonpaths.put(eventTypeIn.getType() + "/" + attribute.getName() + "/" + metadata.getName(), JsonPath.compile(jsonpath)); } catch (IllegalArgumentException|InvalidPathException e) { throw new ConfigurationException("invalid jsonpath expression for metadata "+attribute.getName()+"/"+metadata.getName(), e); } } } } } this.jsonpaths = jsonpaths; }  }
EventMapper { public void setConfiguration(Configuration configuration) throws ConfigurationException { Map<String, JsonPath> jsonpaths = new HashMap<>(); for (EventTypeIn eventTypeIn : configuration.getEventTypeIns()) { for (Attribute attribute : eventTypeIn.getAttributes()) { String jsonpath = attribute.getJsonpath(); if (jsonpath != null) { try { jsonpaths.put(eventTypeIn.getType() + "/" + attribute.getName(), JsonPath.compile(jsonpath)); } catch (IllegalArgumentException|InvalidPathException e) { throw new ConfigurationException("invalid jsonpath expression for attribute "+attribute.getName(), e); } } for (Metadata metadata : attribute.getMetadata()) { jsonpath = metadata.getJsonpath(); if (jsonpath != null) { try { jsonpaths.put(eventTypeIn.getType() + "/" + attribute.getName() + "/" + metadata.getName(), JsonPath.compile(jsonpath)); } catch (IllegalArgumentException|InvalidPathException e) { throw new ConfigurationException("invalid jsonpath expression for metadata "+attribute.getName()+"/"+metadata.getName(), e); } } } } } this.jsonpaths = jsonpaths; }  void setConfiguration(Configuration configuration); Map<String, Object> esperTypeFromEventType(EventType eventType); Event eventFromContextElement(ContextElement contextElement); ContextElement contextElementFromEvent(EventBean eventBean, EventType eventType); Object attributeValueFromEventProperty(Object value, String type); }
EventMapper { public void setConfiguration(Configuration configuration) throws ConfigurationException { Map<String, JsonPath> jsonpaths = new HashMap<>(); for (EventTypeIn eventTypeIn : configuration.getEventTypeIns()) { for (Attribute attribute : eventTypeIn.getAttributes()) { String jsonpath = attribute.getJsonpath(); if (jsonpath != null) { try { jsonpaths.put(eventTypeIn.getType() + "/" + attribute.getName(), JsonPath.compile(jsonpath)); } catch (IllegalArgumentException|InvalidPathException e) { throw new ConfigurationException("invalid jsonpath expression for attribute "+attribute.getName(), e); } } for (Metadata metadata : attribute.getMetadata()) { jsonpath = metadata.getJsonpath(); if (jsonpath != null) { try { jsonpaths.put(eventTypeIn.getType() + "/" + attribute.getName() + "/" + metadata.getName(), JsonPath.compile(jsonpath)); } catch (IllegalArgumentException|InvalidPathException e) { throw new ConfigurationException("invalid jsonpath expression for metadata "+attribute.getName()+"/"+metadata.getName(), e); } } } } } this.jsonpaths = jsonpaths; }  void setConfiguration(Configuration configuration); Map<String, Object> esperTypeFromEventType(EventType eventType); Event eventFromContextElement(ContextElement contextElement); ContextElement contextElementFromEvent(EventBean eventBean, EventType eventType); Object attributeValueFromEventProperty(Object value, String type);  }