Search in sources :

Example 6 with ControllerListener

use of com.willwinder.universalgcodesender.listeners.ControllerListener in project Universal-G-Code-Sender by winder.

the class GrblControllerTest method rawResponseHandlerWithUnknownErrorShouldWriteGenericMessageToConsole.

@Test
public void rawResponseHandlerWithUnknownErrorShouldWriteGenericMessageToConsole() throws Exception {
    // Given
    GrblController instance = new GrblController(mgc);
    instance.setDistanceModeCode("G90");
    instance.setUnitsCode("G21");
    instance.openCommPort("foo", 2400);
    instance.commandSent(new GcodeCommand("G21"));
    ControllerListener controllerListener = mock(ControllerListener.class);
    instance.addListener(controllerListener);
    // When
    instance.rawResponseHandler("error:18");
    // Then
    String genericErrorMessage = "An error was detected while sending 'G21': (error:18) An unknown error has occurred. Streaming has been paused.\n";
    verify(controllerListener, times(1)).messageForConsole(ControllerListener.MessageType.ERROR, genericErrorMessage);
    verify(controllerListener, times(1)).messageForConsole(any(), anyString());
    instance.removeListener(controllerListener);
    assertFalse(instance.getActiveCommand().isPresent());
}
Also used : GcodeCommand(com.willwinder.universalgcodesender.types.GcodeCommand) ControllerListener(com.willwinder.universalgcodesender.listeners.ControllerListener) Test(org.junit.Test) GcodeStreamTest(com.willwinder.universalgcodesender.utils.GcodeStreamTest)

Aggregations

ControllerListener (com.willwinder.universalgcodesender.listeners.ControllerListener)6 GcodeStreamTest (com.willwinder.universalgcodesender.utils.GcodeStreamTest)5 Test (org.junit.Test)5 GcodeCommand (com.willwinder.universalgcodesender.types.GcodeCommand)3