use of org.apache.metron.parsers.interfaces.MessageParser in project metron by apache.
the class MessageParserTest method testNullable.
@Test
public void testNullable() throws Exception {
MessageParser parser = new MessageParser() {
@Override
public void init() {
}
@Override
public List parse(byte[] rawMessage) {
return null;
}
@Override
public boolean validate(Object message) {
return false;
}
@Override
public void configure(Map<String, Object> config) {
}
};
Assert.assertNotNull(parser.parseOptional(null));
Assert.assertFalse(parser.parseOptional(null).isPresent());
}
use of org.apache.metron.parsers.interfaces.MessageParser in project metron by apache.
the class MessageParserTest method testNotNullable.
@Test
public void testNotNullable() throws Exception {
MessageParser parser = new MessageParser() {
@Override
public void init() {
}
@Override
public List parse(byte[] rawMessage) {
return new ArrayList<>();
}
@Override
public boolean validate(Object message) {
return false;
}
@Override
public void configure(Map<String, Object> config) {
}
};
Assert.assertNotNull(parser.parseOptional(null));
Optional<List> ret = parser.parseOptional(null);
Assert.assertTrue(ret.isPresent());
Assert.assertEquals(0, ret.get().size());
}
Aggregations