Search in sources :

Example 1 with GrblFirmwareSettings

use of com.willwinder.universalgcodesender.firmware.GrblFirmwareSettings in project Universal-G-Code-Sender by winder.

the class GrblControllerMockTests method testFillInSettings.

@Test
public void testFillInSettings() {
    GrblController gc = Mockito.spy(new GrblController());
    GrblFirmwareSettings firmwareSettings = Mockito.mock(GrblFirmwareSettings.class);
    Mockito.when(firmwareSettings.getReportingUnits()).thenReturn(Units.MM);
    doReturn(firmwareSettings).when(gc).getFirmwareSettings();
    String description = "Status report options, mask";
    gc.rawResponseListener("$10=100");
    ArgumentCaptor<String> consoleMessageCaptor = ArgumentCaptor.forClass(String.class);
    verify(gc, times(1)).messageForConsole(consoleMessageCaptor.capture());
    assertThat(consoleMessageCaptor.getValue(), containsString(description));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GrblFirmwareSettings(com.willwinder.universalgcodesender.firmware.GrblFirmwareSettings) Test(org.junit.Test)

Example 2 with GrblFirmwareSettings

use of com.willwinder.universalgcodesender.firmware.GrblFirmwareSettings in project Universal-G-Code-Sender by winder.

the class GrblControllerMockTests method testProbeResponse.

@Test
public void testProbeResponse() {
    GrblController gc = Mockito.spy(new GrblController());
    GrblFirmwareSettings firmwareSettings = Mockito.mock(GrblFirmwareSettings.class);
    Mockito.when(firmwareSettings.getReportingUnits()).thenReturn(Units.MM);
    doReturn(firmwareSettings).when(gc).getFirmwareSettings();
    gc.rawResponseListener("[PRB:-192.200,-202.000,-40.400:1]");
    ArgumentCaptor<Position> probeCaptor = ArgumentCaptor.forClass(Position.class);
    verify(gc, times(1)).dispatchProbeCoordinates(probeCaptor.capture());
    assertThat(probeCaptor.getValue(), is(new Position(-192.200, -202.000, -40.400, Units.MM)));
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) GrblFirmwareSettings(com.willwinder.universalgcodesender.firmware.GrblFirmwareSettings) Test(org.junit.Test)

Aggregations

GrblFirmwareSettings (com.willwinder.universalgcodesender.firmware.GrblFirmwareSettings)2 Test (org.junit.Test)2 Position (com.willwinder.universalgcodesender.model.Position)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1