use of org.pentaho.di.engine.api.events.ErrorEvent in project pentaho-kettle by pentaho.
the class MessageEncoderDecoderTest method testErrorEvent.
@Test
public void testErrorEvent() throws Exception {
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("key", "value");
LogEntry logEntry = new LogEntry.LogEntryBuilder().withMessage("log message").withLogLevel(LogLevel.DEBUG).withTimestamp(new Date()).withExtras(hashMap).build();
ErrorEvent errorEvent = new ErrorEvent(new RemoteSource(ModelType.TRANSFORMATION), logEntry);
String sMessage = encoder.encode(errorEvent);
Message decodeMessage = decoder.decode(sMessage);
assertTrue(((RemoteSource) errorEvent.getSource()).getModelType() == ((RemoteSource) ((ErrorEvent) decodeMessage).getSource()).getModelType());
LogEntry decodeLogEntry = (LogEntry) ((ErrorEvent) decodeMessage).getData();
assertTrue(logEntry.getMessage().equals(decodeLogEntry.getMessage()));
assertTrue(logEntry.getLogLogLevel().equals(decodeLogEntry.getLogLogLevel()));
assertTrue(logEntry.getTimestamp().getTime() == decodeLogEntry.getTimestamp().getTime());
assertTrue(logEntry.getExtras().hashCode() == decodeLogEntry.getExtras().hashCode());
}
Aggregations