Search in sources :

Example 1 with StatusMessage

use of com.google.api.services.clouddebugger.v2.model.StatusMessage in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudDebugProcessStateTest method createBreakpoint.

private static Breakpoint createBreakpoint(String id, Boolean isFinal, int finalTimeSeconds, String locationPath, Integer locationLine, Boolean isError, String statusMessage) {
    Breakpoint result = new Breakpoint();
    result.setId(id);
    result.setIsFinalState(isFinal);
    if (Boolean.TRUE.equals(isFinal)) {
        Calendar calendar = // gets a calendar using the default time zone and locale.
        Calendar.getInstance();
        calendar.add(Calendar.SECOND, finalTimeSeconds);
        DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
        result.setFinalTime(formatter.print(calendar.getTimeInMillis()));
    }
    SourceLocation location = new SourceLocation();
    location.setPath(locationPath);
    location.setLine(locationLine);
    result.setLocation(location);
    StatusMessage status = new StatusMessage();
    status.setIsError(isError);
    FormatMessage message = new FormatMessage();
    message.setFormat(statusMessage);
    status.setDescription(message);
    result.setStatus(status);
    return result;
}
Also used : SourceLocation(com.google.api.services.clouddebugger.v2.model.SourceLocation) Breakpoint(com.google.api.services.clouddebugger.v2.model.Breakpoint) FormatMessage(com.google.api.services.clouddebugger.v2.model.FormatMessage) Calendar(java.util.Calendar) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) StatusMessage(com.google.api.services.clouddebugger.v2.model.StatusMessage)

Example 2 with StatusMessage

use of com.google.api.services.clouddebugger.v2.model.StatusMessage in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudDebugProcessTest method testOnBreakpointListChangedSetsErrorMessageAndUpdatesBreakpointPresentation.

public void testOnBreakpointListChangedSetsErrorMessageAndUpdatesBreakpointPresentation() throws Exception {
    // override the default XBreakpointManager implementation with mock to use Mockito.verify()
    XBreakpointManager breakpointManager = mock(XBreakpointManager.class);
    XDebuggerManager debuggerManager = mock(XDebuggerManager.class);
    when(debuggerManager.getBreakpointManager()).thenReturn(breakpointManager);
    ((ProjectImpl) getProject()).registerComponentInstance(XDebuggerManager.class, debuggerManager);
    ArrayList<Breakpoint> breakpoints = new ArrayList<Breakpoint>();
    Breakpoint breakpoint = new Breakpoint();
    breakpoint.setId("breakpointId").setIsFinalState(Boolean.TRUE).setStatus(new StatusMessage().setIsError(Boolean.TRUE));
    breakpoints.add(breakpoint);
    CloudDebugProcessState processState = mock(CloudDebugProcessState.class);
    when(processState.getCurrentServerBreakpointList()).thenReturn(ContainerUtil.immutableList(breakpoints));
    XLineBreakpointImpl xLineBreakpointImpl = mock(XLineBreakpointImpl.class);
    CloudLineBreakpoint cloudLineBreakpoint = mockCloudLineBreakpoint("mock error message", xLineBreakpointImpl);
    when(xLineBreakpointImpl.getUserData(com.intellij.debugger.ui.breakpoints.Breakpoint.DATA_KEY)).thenReturn(cloudLineBreakpoint);
    CloudBreakpointHandler breakpointHandler = mock(CloudBreakpointHandler.class);
    when(breakpointHandler.getEnabledXBreakpoint(breakpoint)).thenReturn(xLineBreakpointImpl);
    process.setBreakpointHandler(breakpointHandler);
    process.initialize(processState);
    process.onBreakpointListChanged(mock(CloudDebugProcessState.class));
    verify(cloudLineBreakpoint).setErrorMessage(eq("General error"));
    verify(cloudLineBreakpoint).getXBreakpoint();
    verify(cloudLineBreakpoint).getSetIcon(Matchers.anyBoolean());
    verify(cloudLineBreakpoint).getErrorMessage();
    verify(breakpointManager).updateBreakpointPresentation(same(xLineBreakpointImpl), any(Icon.class), eq("General error"));
    process.getStateController().stopBackgroundListening();
}
Also used : Breakpoint(com.google.api.services.clouddebugger.v2.model.Breakpoint) CloudLineBreakpoint(com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType.CloudLineBreakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XBreakpointManager(com.intellij.xdebugger.breakpoints.XBreakpointManager) XLineBreakpointImpl(com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl) CloudLineBreakpoint(com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType.CloudLineBreakpoint) ProjectImpl(com.intellij.openapi.project.impl.ProjectImpl) ArrayList(java.util.ArrayList) XDebuggerManager(com.intellij.xdebugger.XDebuggerManager) Icon(javax.swing.Icon) StatusMessage(com.google.api.services.clouddebugger.v2.model.StatusMessage)

Aggregations

Breakpoint (com.google.api.services.clouddebugger.v2.model.Breakpoint)2 StatusMessage (com.google.api.services.clouddebugger.v2.model.StatusMessage)2 FormatMessage (com.google.api.services.clouddebugger.v2.model.FormatMessage)1 SourceLocation (com.google.api.services.clouddebugger.v2.model.SourceLocation)1 CloudLineBreakpoint (com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType.CloudLineBreakpoint)1 ProjectImpl (com.intellij.openapi.project.impl.ProjectImpl)1 XDebuggerManager (com.intellij.xdebugger.XDebuggerManager)1 XBreakpointManager (com.intellij.xdebugger.breakpoints.XBreakpointManager)1 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)1 XLineBreakpointImpl (com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Icon (javax.swing.Icon)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1