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());
}
Aggregations