use of org.graylog2.contentpacks.model.entities.references.Reference in project graylog2-server by Graylog2.
the class ReferenceConverterTest method convertDoubleValue.
@Test
public void convertDoubleValue() {
final Reference reference = createReference("double", 10d);
assertThat(reference).isEqualTo(ValueReference.of(10d));
}
use of org.graylog2.contentpacks.model.entities.references.Reference in project graylog2-server by Graylog2.
the class FunctionsSnippetsTest method jsonpath.
@Test
public void jsonpath() {
final String json = "{\n" + " \"store\": {\n" + " \"book\": [\n" + " {\n" + " \"category\": \"reference\",\n" + " \"author\": \"Nigel Rees\",\n" + " \"title\": \"Sayings of the Century\",\n" + " \"price\": 8.95\n" + " },\n" + " {\n" + " \"category\": \"fiction\",\n" + " \"author\": \"Evelyn Waugh\",\n" + " \"title\": \"Sword of Honour\",\n" + " \"price\": 12.99\n" + " },\n" + " {\n" + " \"category\": \"fiction\",\n" + " \"author\": \"Herman Melville\",\n" + " \"title\": \"Moby Dick\",\n" + " \"isbn\": \"0-553-21311-3\",\n" + " \"price\": 8.99\n" + " },\n" + " {\n" + " \"category\": \"fiction\",\n" + " \"author\": \"J. R. R. Tolkien\",\n" + " \"title\": \"The Lord of the Rings\",\n" + " \"isbn\": \"0-395-19395-8\",\n" + " \"price\": 22.99\n" + " }\n" + " ],\n" + " \"bicycle\": {\n" + " \"color\": \"red\",\n" + " \"price\": 19.95\n" + " }\n" + " },\n" + " \"expensive\": 10\n" + "}";
final Rule rule = parser.parseRule(ruleForTest(), false);
final Message message = evaluateRule(rule, new Message(json, "test", Tools.nowUTC()));
assertThat(message.hasField("author_first")).isTrue();
assertThat(message.getField("author_first")).isEqualTo("Nigel Rees");
assertThat(message.hasField("author_last")).isTrue();
assertThat(message.hasField("this_should_exist")).isTrue();
}
Aggregations