use of com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType.CloudLineBreakpoint in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessTest method mockCloudLineBreakpoint.
@NotNull
private // mock behavior except for get/setErrorMessage() to simplify code
CloudLineBreakpoint mockCloudLineBreakpoint(String errorMessage, XLineBreakpointImpl xLineBreakpoint) {
CloudLineBreakpoint breakpoint = mock(CloudLineBreakpoint.class);
when(breakpoint.getSetIcon(Matchers.anyBoolean())).thenReturn(mock(Icon.class));
when(breakpoint.getXBreakpoint()).thenReturn(xLineBreakpoint);
doCallRealMethod().when(breakpoint).setErrorMessage(anyString());
when(breakpoint.getErrorMessage()).thenCallRealMethod();
breakpoint.setErrorMessage(errorMessage);
return breakpoint;
}
use of com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType.CloudLineBreakpoint in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebugProcessTest method testUpdateBreakpointRepresentationUsesBreakpointErrorMsgAndIcon.
public void testUpdateBreakpointRepresentationUsesBreakpointErrorMsgAndIcon() throws Exception {
XBreakpointManager breakpointManager = mock(XBreakpointManager.class);
CloudDebugProcess cloudDebugProcess = mockCloudDebugProcess(breakpointManager, mock(XDebugSession.class));
CloudLineBreakpoint breakpoint = mockCloudLineBreakpoint("mock error message", mock(XLineBreakpointImpl.class));
XLineBreakpoint xBreakpoint = mock(XLineBreakpoint.class);
when(breakpoint.getXBreakpoint()).thenReturn(xBreakpoint);
Icon icon = mock(Icon.class);
when(breakpoint.getSetIcon(anyBoolean())).thenReturn(icon);
cloudDebugProcess.updateBreakpointPresentation(breakpoint);
verify(breakpoint).getXBreakpoint();
verify(breakpoint).getSetIcon(Matchers.anyBoolean());
verify(breakpoint).getErrorMessage();
verify(breakpointManager).updateBreakpointPresentation(xBreakpoint, icon, "mock error message");
}
use of com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType.CloudLineBreakpoint in project google-cloud-intellij by GoogleCloudPlatform.
the class DoUpdateIdeWithBreakpointTest method runUpdateIdeWithBreakpoint.
@Test
public void runUpdateIdeWithBreakpoint() throws Exception {
when(virtualFile.getUrl()).thenReturn(MOCK_FILE_URL);
when(xLineBreakpoint.getUserData(com.intellij.debugger.ui.breakpoints.Breakpoint.DATA_KEY)).thenReturn(cloudLineBreakpoint);
when(xLineBreakpoint.getProperties()).thenReturn(cloudLineBreakpointProperties);
when(breakpointManager.addLineBreakpoint(any(CloudLineBreakpointType.class), anyString(), anyInt(), eq(cloudLineBreakpointProperties))).thenReturn(xLineBreakpoint);
Breakpoint serverBreakpoint = new Breakpoint();
serverBreakpoint.setId("mock-breakpoint-id").setCondition(MOCK_BREAKPOINT_CONDITION).setExpressions(Lists.newArrayList(MOCK_BREAKPOINT_EXPRESSION));
HashMap<String, XBreakpoint> ideBreakpoints = new HashMap<>();
int line = 1;
new DoUpdateIdeWithBreakpoint(breakpointManager, virtualFile, line, cloudLineBreakpointProperties, serverBreakpoint, ideBreakpoints, cloudDebugProcess).run();
verify(breakpointManager).addLineBreakpoint(any(), eq(MOCK_FILE_URL), eq(line), eq(cloudLineBreakpointProperties));
verify(xLineBreakpoint).putUserData(keyArgumentCaptor.capture(), eq("mock-breakpoint-id"));
assertThat(keyArgumentCaptor.getValue().toString()).isEqualTo(// CloudBreakpointHandler.CLOUD_ID
"CloudId");
assertThat(ideBreakpoints.get("mock-breakpoint-id")).isEqualTo(xLineBreakpoint);
verify(xLineBreakpoint).setCondition(eq(MOCK_BREAKPOINT_CONDITION));
assertThat(cloudLineBreakpointProperties.getWatchExpressions()).hasLength(1);
assertThat(cloudLineBreakpointProperties.getWatchExpressions()[0]).isEqualTo(MOCK_BREAKPOINT_EXPRESSION);
assertFalse(cloudLineBreakpointProperties.isCreatedByServer());
verify(cloudDebugProcess).updateBreakpointPresentation(cloudLineBreakpoint);
}
use of com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType.CloudLineBreakpoint in project google-cloud-intellij by GoogleCloudPlatform.
the class BreakpointErrorStatusPanel method loadFrom.
@Override
public void loadFrom(@NotNull XLineBreakpoint<CloudLineBreakpointProperties> breakpoint) {
XBreakpointBase lineBreakpointImpl = breakpoint instanceof XBreakpointBase ? (XBreakpointBase) breakpoint : null;
Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint);
CloudLineBreakpoint cloudBreakpoint = null;
if (javaBreakpoint instanceof CloudLineBreakpoint) {
cloudBreakpoint = (CloudLineBreakpoint) javaBreakpoint;
}
if (cloudBreakpoint == null || lineBreakpointImpl == null) {
return;
}
errorPanel.setVisible(cloudBreakpoint.hasError());
if (cloudBreakpoint.hasError()) {
errorLabel.setForeground(JBColor.RED);
errorDescription.setText(cloudBreakpoint.getErrorMessage());
}
}
Aggregations