Upgrading java to java 11 (java 13 in tests) (#405)

Upgrading Storm to 2.3.0
Supporting downloading http enrichment tables
Remove multiline string dependency
This commit is contained in:
Marian Novotny
2021-11-04 16:12:54 +00:00
committed by GitHub
parent 2628339ddb
commit 3415ce3909
131 changed files with 4013 additions and 4538 deletions

View File

@@ -1,6 +1,5 @@
package uk.co.gresearch.siembol.parsers.application.factory;
import org.adrianwalker.multilinestring.Multiline;
import org.junit.Assert;
import org.junit.Test;
@@ -10,136 +9,128 @@ public class ParsingApplicationFactoryImplTest {
factory = new ParsingApplicationFactoryImpl();
}
/**
*{
* "parsing_app_name": "test",
* "parsing_app_version": 1,
* "parsing_app_author": "dummy",
* "parsing_app_description": "Description of parser application",
* "parsing_app_settings": {
* "input_topics": [
* "secret"
* ],
* "error_topic": "error",
* "input_parallelism": 1,
* "parsing_parallelism": 2,
* "output_parallelism": 3,
* "parsing_app_type": "single_parser"
* },
* "parsing_settings": {
* "single_parser": {
* "parser_name": "single",
* "output_topic": "output"
* }
* }
* }
**/
@Multiline
public static String simpleSingleApplicationParser;
private final String simpleSingleApplicationParser = """
{
"parsing_app_name": "test",
"parsing_app_version": 1,
"parsing_app_author": "dummy",
"parsing_app_description": "Description of parser application",
"parsing_app_settings": {
"input_topics": [
"secret"
],
"error_topic": "error",
"input_parallelism": 1,
"parsing_parallelism": 2,
"output_parallelism": 3,
"parsing_app_type": "single_parser"
},
"parsing_settings": {
"single_parser": {
"parser_name": "single",
"output_topic": "output"
}
}
}
""";
private final String simpleRoutingApplicationParser = """
{
"parsing_app_name": "test",
"parsing_app_version": 1,
"parsing_app_author": "dummy",
"parsing_app_description": "Description of parser application",
"parsing_app_settings": {
"input_topics": [
"secret"
],
"error_topic": "error",
"input_parallelism": 1,
"parsing_parallelism": 2,
"output_parallelism": 3,
"parsing_app_type": "router_parsing"
},
"parsing_settings": {
"routing_parser": {
"router_parser_name": "router",
"routing_field": "host",
"routing_message": "msg",
"merged_fields": [
"timestamp",
"syslog_host"
],
"default_parser": {
"parser_name": "default",
"output_topic": "output_default"
},
"parsers": [
{
"routing_field_pattern": "secret",
"parser_properties": {
"parser_name": "single",
"output_topic": "out_secret"
}
}
]
}
}
}
""";
/**
* {
* "parsing_app_name": "test",
* "parsing_app_version": 1,
* "parsing_app_author": "dummy",
* "parsing_app_description": "Description of parser application",
* "parsing_app_settings": {
* "input_topics": [
* "secret"
* ],
* "error_topic": "error",
* "input_parallelism": 1,
* "parsing_parallelism": 2,
* "output_parallelism": 3,
* "parsing_app_type": "router_parsing"
* },
* "parsing_settings": {
* "routing_parser": {
* "router_parser_name": "router",
* "routing_field": "host",
* "routing_message": "msg",
* "merged_fields": [
* "timestamp",
* "syslog_host"
* ],
* "default_parser": {
* "parser_name": "default",
* "output_topic": "output_default"
* },
* "parsers": [
* {
* "routing_field_pattern": "secret",
* "parser_properties": {
* "parser_name": "single",
* "output_topic": "out_secret"
* }
* }
* ]
* }
* }
* }
**/
@Multiline
public static String simpleRoutingApplicationParser;
/**
* {
* "parsers_version": 1,
* "parsers_configurations": [
* {
* "parser_description": "for testing single app parser",
* "parser_version": 2,
* "parser_name": "single",
* "parser_author": "dummy",
* "parser_attributes": {
* "parser_type": "generic"
* }
* },
* {
* "parser_description": "for testing routing app paerser",
* "parser_version": 2,
* "parser_name": "router",
* "parser_author": "dummy",
* "parser_attributes": {
* "parser_type": "generic"
* }
* },
* {
* "parser_description": "for testing routing app parser",
* "parser_version": 2,
* "parser_name": "default",
* "parser_author": "dummy",
* "parser_attributes": {
* "parser_type": "generic"
* }
* }
* ]
* }
**/
@Multiline
public static String testParsersConfigs;
private final String testParsersConfigs = """
{
"parsers_version": 1,
"parsers_configurations": [
{
"parser_description": "for testing single app parser",
"parser_version": 2,
"parser_name": "single",
"parser_author": "dummy",
"parser_attributes": {
"parser_type": "generic"
}
},
{
"parser_description": "for testing routing app parser",
"parser_version": 2,
"parser_name": "router",
"parser_author": "dummy",
"parser_attributes": {
"parser_type": "generic"
}
},
{
"parser_description": "for testing routing app parser",
"parser_version": 2,
"parser_name": "default",
"parser_author": "dummy",
"parser_attributes": {
"parser_type": "generic"
}
}
]
}
""";
@Test
public void testGetSchema() {
ParsingApplicationFactoryResult schemaResult = factory.getSchema();
Assert.assertTrue(schemaResult.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.OK);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.OK, schemaResult.getStatusCode());
Assert.assertFalse(schemaResult.getAttributes().getJsonSchema().isEmpty());
}
@Test
public void testValidationSingleGood() {
ParsingApplicationFactoryResult result = factory.validateConfiguration(simpleSingleApplicationParser);
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.OK);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.OK, result.getStatusCode());
}
@Test
public void testValidationSingleFail() {
ParsingApplicationFactoryResult result = factory.validateConfiguration(simpleSingleApplicationParser
.replace("error_topic", "dummy"));
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage().contains("error_topic"));
}
@@ -147,7 +138,7 @@ public class ParsingApplicationFactoryImplTest {
public void testValidationSingleFail2() {
ParsingApplicationFactoryResult result = factory.validateConfiguration(simpleSingleApplicationParser
.replace("\"parsing_parallelism\": 2,", ""));
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame( ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage()
.contains("missing required properties ([\"parsing_parallelism\"])"));
}
@@ -155,7 +146,7 @@ public class ParsingApplicationFactoryImplTest {
@Test
public void testCreationSingleGood() {
ParsingApplicationFactoryResult result = factory.create(simpleSingleApplicationParser, testParsersConfigs);
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.OK);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.OK, result.getStatusCode());
Assert.assertEquals("test", result.getAttributes().getName());
Assert.assertEquals(1, result.getAttributes().getInputParallelism().intValue());
Assert.assertEquals(2, result.getAttributes().getParsingParallelism().intValue());
@@ -169,14 +160,14 @@ public class ParsingApplicationFactoryImplTest {
ParsingApplicationFactoryResult result = factory.create(
simpleSingleApplicationParser.replace("error_topic", "dummy"),
testParsersConfigs);
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage().contains("error_topic"));
}
@Test
public void testCreationSingleWrongParserConfigs() {
ParsingApplicationFactoryResult result = factory.create(simpleSingleApplicationParser, "INVALID");
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage().contains("INVALID"));
}
@@ -184,28 +175,28 @@ public class ParsingApplicationFactoryImplTest {
public void testCreationSingleMissingParserConfigs() {
ParsingApplicationFactoryResult result = factory.create(simpleSingleApplicationParser,
testParsersConfigs.replace("single", "unwanted"));
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage().contains("Missing parser: single"));
}
@Test
public void testValidationRoutingGood() {
ParsingApplicationFactoryResult result = factory.validateConfiguration(simpleRoutingApplicationParser);
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.OK);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.OK, result.getStatusCode());
}
@Test
public void testValidationRoutingFail() {
ParsingApplicationFactoryResult result = factory.validateConfiguration(simpleRoutingApplicationParser
.replace("error_topic", "dummy"));
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage().contains("error_topic"));
}
@Test
public void testCreationRoutingGood() {
ParsingApplicationFactoryResult result = factory.create(simpleRoutingApplicationParser, testParsersConfigs);
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.OK);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.OK, result.getStatusCode());
Assert.assertEquals("test", result.getAttributes().getName());
Assert.assertEquals(1, result.getAttributes().getInputParallelism().intValue());
Assert.assertEquals(2, result.getAttributes().getParsingParallelism().intValue());
@@ -219,14 +210,14 @@ public class ParsingApplicationFactoryImplTest {
ParsingApplicationFactoryResult result = factory.create(
simpleRoutingApplicationParser.replace("error_topic", "dummy"),
testParsersConfigs);
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage().contains("error_topic"));
}
@Test
public void testCreationRoutingWrongParserConfigs() {
ParsingApplicationFactoryResult result = factory.create(simpleRoutingApplicationParser, "INVALID");
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage().contains("INVALID"));
}
@@ -234,7 +225,7 @@ public class ParsingApplicationFactoryImplTest {
public void testCreationRoutingMissingRouterParserConfigs() {
ParsingApplicationFactoryResult result = factory.create(simpleRoutingApplicationParser,
testParsersConfigs.replace("router", "unwanted"));
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage().contains("Missing parser: router"));
}
@@ -242,7 +233,7 @@ public class ParsingApplicationFactoryImplTest {
public void testCreationRoutingMissingDefaultParserConfigs() {
ParsingApplicationFactoryResult result = factory.create(simpleRoutingApplicationParser,
testParsersConfigs.replace("default", "unwanted"));
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage().contains("Missing parser: default"));
}
@@ -250,7 +241,7 @@ public class ParsingApplicationFactoryImplTest {
public void testCreationRoutingMissingParserConfigs() {
ParsingApplicationFactoryResult result = factory.create(simpleRoutingApplicationParser,
testParsersConfigs.replace("single", "unwanted"));
Assert.assertTrue(result.getStatusCode() == ParsingApplicationFactoryResult.StatusCode.ERROR);
Assert.assertSame(ParsingApplicationFactoryResult.StatusCode.ERROR, result.getStatusCode());
Assert.assertTrue(result.getAttributes().getMessage().contains("Missing parser: single"));
}
}

View File

@@ -1,6 +1,5 @@
package uk.co.gresearch.siembol.parsers.application.parsing;
import org.adrianwalker.multilinestring.Multiline;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -17,38 +16,34 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class RoutingParsingApplicationParserTest {
/**
* {
*
* "a": "string",
* "b": 1,
* "c": true
* }
**/
@Multiline
public static String metadata;
private final String metadata = """
{
"a": "string",
"b": 1,
"c": true
}
""";
private SerializableSiembolParser routerParser;
private SerializableSiembolParser defaultParser;
private SerializableSiembolParser routedParser1;
private SerializableSiembolParser routedParser2;
private String routingConditionField = "test_field";
private String routingMessageField = "original_string";
private final String routingConditionField = "test_field";
private final String routingMessageField = "original_string";
private RoutingParsingApplicationParser appParser;
private Map<String, Object> message1;
private Map<String, Object> message2;
private List<Map<String, Object>> parsed;
private String errorTopic = "error";
private String outputTopic = "output";
private byte[] input = "test".getBytes();
private final String errorTopic = "error";
private final String outputTopic = "output";
private final byte[] input = "test".getBytes();
private ParserResult routerParserResult;
private ParserResult routedParserResult1;
private ParserResult routedParserResult2;
TimeProvider timeProvider;
long currentTime = 1L;
@Before
public void setUp() {
timeProvider = Mockito.mock(TimeProvider.class);
@@ -95,7 +90,7 @@ public class RoutingParsingApplicationParserTest {
}
@Test(expected = IllegalArgumentException.class)
public void testMissingARguments() {
public void testMissingArguments() {
appParser = RoutingParsingApplicationParser.builder()
.errorTopic(errorTopic)
.build();
@@ -138,13 +133,13 @@ public class RoutingParsingApplicationParserTest {
Assert.assertEquals(outputTopic, result.get(0).getTopic());
Assert.assertEquals(1, result.size());
Assert.assertEquals(1, result.get(0).getMessages().size());
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("output_field" + "\":\"routed"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("original_string" + "\":\"test"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("timestamp" + "\":3"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"default-parser\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"default-parser\""));
}
@Test
@@ -194,14 +189,14 @@ public class RoutingParsingApplicationParserTest {
Assert.assertEquals(outputTopic, result.get(0).getTopic());
Assert.assertEquals(1, result.size());
Assert.assertEquals(1, result.get(0).getMessages().size());
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("output_field" + "\":\"routed"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("original_string" + "\":\"test"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("timestamp" + "\":3"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("guid" + "\":"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"default-parser\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"default-parser\""));
}
@Test
@@ -285,13 +280,13 @@ public class RoutingParsingApplicationParserTest {
Assert.assertEquals(outputTopic, result.get(0).getTopic());
Assert.assertEquals(1, result.size());
Assert.assertEquals(1, result.get(0).getMessages().size());
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("output_field" + "\":\"routed"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("original_string" + "\":\"test"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("timestamp" + "\":3"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"default-parser\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"default-parser\""));
}
@Test
@@ -320,10 +315,10 @@ public class RoutingParsingApplicationParserTest {
Assert.assertEquals(2, result.size());
Assert.assertEquals("dummy1", result.get(0).getTopic());
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"routed-parser1\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"routed-parser1\""));
Assert.assertEquals("dummy2", result.get(1).getTopic());
Assert.assertTrue(result.get(1).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"routed-parser2\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"routed-parser2\""));
}
@Test
@@ -335,7 +330,7 @@ public class RoutingParsingApplicationParserTest {
.routingMessageField(routingMessageField)
.addParser("dummy1", routedParser1, "a")
.addParser("dummy2", routedParser2, "b")
.mergedFields(Arrays.asList("timestamp"))
.mergedFields(List.of("timestamp"))
.name("test")
.errorTopic(errorTopic)
.timeProvider(timeProvider)
@@ -356,9 +351,9 @@ public class RoutingParsingApplicationParserTest {
Assert.assertEquals("dummy2", result.get(1).getTopic());
Assert.assertTrue(result.get(1).getMessages().get(0).contains("timestamp" + "\":2"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"routed-parser1\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"routed-parser1\""));
Assert.assertTrue(result.get(1).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"routed-parser2\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"routed-parser2\""));
}
@Test
@@ -370,7 +365,7 @@ public class RoutingParsingApplicationParserTest {
.routingMessageField(routingMessageField)
.addParser("dummy1", routedParser1, "a")
.addParser("dummy2", routedParser2, "b")
.mergedFields(Arrays.asList("timestamp"))
.mergedFields(List.of("timestamp"))
.name("test")
.errorTopic(errorTopic)
.timeProvider(timeProvider)
@@ -392,9 +387,9 @@ public class RoutingParsingApplicationParserTest {
Assert.assertEquals("dummy2", result.get(1).getTopic());
Assert.assertTrue(result.get(1).getMessages().get(0).contains("timestamp" + "\":2"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"routed-parser1\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"routed-parser1\""));
Assert.assertTrue(result.get(1).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"routed-parser2\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"routed-parser2\""));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("guid" + "\":"));
Assert.assertTrue(result.get(1).getMessages().get(0).contains("guid" + "\":"));
}
@@ -408,7 +403,7 @@ public class RoutingParsingApplicationParserTest {
.routingMessageField(routingMessageField)
.addParser("dummy1", routedParser1, "a")
.addParser("dummy2", routedParser2, "b")
.mergedFields(Arrays.asList("timestamp"))
.mergedFields(List.of("timestamp"))
.name("test")
.errorTopic(errorTopic)
.timeProvider(timeProvider)
@@ -431,6 +426,6 @@ public class RoutingParsingApplicationParserTest {
Assert.assertEquals("dummy2", result.get(1).getTopic());
Assert.assertTrue(result.get(1).getMessages().get(0).contains("timestamp" + "\":2"));
Assert.assertTrue(result.get(1).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"routed-parser2\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"routed-parser2\""));
}
}

View File

@@ -1,6 +1,5 @@
package uk.co.gresearch.siembol.parsers.application.parsing;
import org.adrianwalker.multilinestring.Multiline;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -17,26 +16,24 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class SingleApplicationParserTest {
/**
* {
*
* "a": "string",
* "b": 1,
* "c": true
* }
**/
@Multiline
public static String metadata;
private final String metadata = """
{
"a": "string",
"b": 1,
"c": true
}
""";
private SerializableSiembolParser siembolParser;
private String sourceType = "test_type";
private final String sourceType = "test_type";
private SingleApplicationParser appParser;
private Map<String, Object> message1;
private Map<String, Object> message2;
private List<Map<String, Object>> parsed;
private String errorTopic = "error";
private String outputTopic = "output";
private byte[] input = "test".getBytes();
private final String errorTopic = "error";
private final String outputTopic = "output";
private final byte[] input = "test".getBytes();
private ParserResult parserResult;
TimeProvider timeProvider;
long currentTime = 1L;
@@ -65,14 +62,14 @@ public class SingleApplicationParserTest {
}
@Test(expected = IllegalArgumentException.class)
public void testMissingARguments() {
public void testMissingArguments() {
appParser = SingleApplicationParser.builder()
.errorTopic(errorTopic)
.build();
}
@Test(expected = IllegalArgumentException.class)
public void testMissingARguments2() throws Exception {
public void testMissingArguments2() throws Exception {
appParser = SingleApplicationParser.builder()
.parser(outputTopic, siembolParser)
.name("test")
@@ -97,16 +94,16 @@ public class SingleApplicationParserTest {
Assert.assertEquals(1, result.size());
Assert.assertEquals(2, result.get(0).getMessages().size());
Assert.assertEquals(outputTopic, result.get(0).getTopic());
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_field" + "\":\"a"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("timestamp" + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"test_type\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
SiembolMessageFields.SENSOR_TYPE + "\":\"test_type\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("test_field" + "\":\"b"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("timestamp" + "\":2"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"test_type\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"test_type\""));
}
@Test
@@ -126,12 +123,12 @@ public class SingleApplicationParserTest {
Assert.assertEquals(1, result.size());
Assert.assertEquals(1, result.get(0).getMessages().size());
Assert.assertEquals(outputTopic, result.get(0).getTopic());
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_field" + "\":\"a"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("timestamp" + "\":1"));
Assert.assertFalse(result.get(0).getMessages().get(0).contains("guid" + "\":"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"test_type\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"test_type\""));
}
@Test
@@ -152,12 +149,12 @@ public class SingleApplicationParserTest {
Assert.assertEquals(1, result.size());
Assert.assertEquals(1, result.get(0).getMessages().size());
Assert.assertEquals(outputTopic, result.get(0).getTopic());
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_field" + "\":\"a"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("timestamp" + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("guid" + "\":"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"test_type\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"test_type\""));
}
@Test
@@ -256,22 +253,22 @@ public class SingleApplicationParserTest {
Assert.assertEquals(1, result.size());
Assert.assertEquals(2, result.get(0).getMessages().size());
Assert.assertEquals(outputTopic, result.get(0).getTopic());
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_field" + "\":\"a"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_metadata:a" + "\":\"string\""));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_metadata:b" + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_metadata:c" + "\":true"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("timestamp" + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"test_type\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
SiembolMessageFields.SENSOR_TYPE + "\":\"test_type\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("test_field" + "\":\"b"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("timestamp" + "\":2"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("test_metadata:a" + "\":\"string\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("test_metadata:b" + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("test_metadata:c" + "\":true"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"test_type\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"test_type\""));
}
@Test
@@ -293,7 +290,7 @@ public class SingleApplicationParserTest {
Assert.assertEquals(1, result.size());
Assert.assertEquals(2, result.get(0).getMessages().size());
Assert.assertEquals(outputTopic, result.get(0).getTopic());
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_field" + "\":\"a"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_metadata:a" + "\":\"string\""));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_metadata:b" + "\":1"));
@@ -301,15 +298,15 @@ public class SingleApplicationParserTest {
Assert.assertTrue(result.get(0).getMessages().get(0).contains("timestamp" + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("guid" + "\":"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"test_type\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
SiembolMessageFields.SENSOR_TYPE + "\":\"test_type\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("test_field" + "\":\"b"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("timestamp" + "\":2"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("test_metadata:a" + "\":\"string\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("test_metadata:b" + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("test_metadata:c" + "\":true"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"test_type\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"test_type\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("guid" + "\":"));
}
@@ -330,21 +327,21 @@ public class SingleApplicationParserTest {
Assert.assertEquals(1, result.size());
Assert.assertEquals(2, result.get(0).getMessages().size());
Assert.assertEquals(outputTopic, result.get(0).getTopic());
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("test_field" + "\":\"a"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("a" + "\":\"string\""));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("b" + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("c" + "\":true"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains("timestamp" + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(0).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"test_type\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(SiembolMessageFields.PARSING_TIME.toString() + "\":1"));
SiembolMessageFields.SENSOR_TYPE + "\":\"test_type\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(SiembolMessageFields.PARSING_TIME + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("test_field" + "\":\"b"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("timestamp" + "\":2"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("a" + "\":\"string\""));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("b" + "\":1"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains("c" + "\":true"));
Assert.assertTrue(result.get(0).getMessages().get(1).contains(
SiembolMessageFields.SENSOR_TYPE.toString() + "\":\"test_type\""));
SiembolMessageFields.SENSOR_TYPE + "\":\"test_type\""));
}
}