Search in sources :

Example 1 with ErrorEvent

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());
}
Also used : HashMap(java.util.HashMap) ErrorEvent(org.pentaho.di.engine.api.events.ErrorEvent) LogEntry(org.pentaho.di.engine.api.reporting.LogEntry) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Date (java.util.Date)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 ErrorEvent (org.pentaho.di.engine.api.events.ErrorEvent)1 LogEntry (org.pentaho.di.engine.api.reporting.LogEntry)1