Esempio n. 1
0
  /** Tests if a log message is sent as expected. */
  @Test
  public void testSendLogMessageAsConsoleRow() {
    Capture<ConsoleRow> consoleRowCapture = new Capture<>();
    ComponentExecutionRelatedInstances compExeRelatedInstances =
        createComponentExecutionRelatedInstances(consoleRowCapture);
    ConsoleRowsSender consoleRowsSender = new ConsoleRowsSender(compExeRelatedInstances);

    String payload = "some message";
    consoleRowsSender.sendLogMessageAsConsoleRow(ConsoleRow.Type.TOOL_ERROR, payload);

    ConsoleRow capturedConsoleRow =
        verifyAfterConsoleRowSent(consoleRowCapture, ConsoleRow.Type.TOOL_ERROR);
    assertEquals(payload, capturedConsoleRow.getPayload());
  }
 private ConsoleRowsSender createConsoleRowsSenderMock(
     Capture<ConsoleRow.Type> consoleRowTypeCapture, Capture<String> logMessageCapture) {
   ConsoleRowsSender consoleRowsSenderMock = EasyMock.createStrictMock(ConsoleRowsSender.class);
   if (consoleRowTypeCapture != null) {
     consoleRowsSenderMock.sendLogMessageAsConsoleRow(
         EasyMock.capture(consoleRowTypeCapture),
         EasyMock.capture(logMessageCapture),
         EasyMock.anyInt());
     EasyMock.expectLastCall();
   }
   consoleRowsSenderMock.sendLogFileWriteTriggerAsConsoleRow();
   EasyMock.expectLastCall();
   EasyMock.replay(consoleRowsSenderMock);
   return consoleRowsSenderMock;
 }