Search in sources :

Example 1 with CloudBreakpointHandler

use of com.google.cloud.tools.intellij.debugger.CloudBreakpointHandler in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudDebugHistoricalSnapshotsTest method testOnBreakpointListChanged.

@Test
public void testOnBreakpointListChanged() throws InterruptedException {
    CloudDebugHistoricalSnapshots snapshots = new CloudDebugHistoricalSnapshots(handler);
    Breakpoint bp1 = new Breakpoint();
    bp1.setId("an ID");
    bp1.setFinalTime("2015-08-22T05:23:34.123Z");
    bp1.setIsFinalState(true);
    SourceLocation location = new SourceLocation();
    location.setPath("foo/bar/baz");
    location.setLine(12);
    bp1.setLocation(location);
    List<Breakpoint> breakpoints = new ArrayList<Breakpoint>();
    breakpoints.add(bp1);
    Mockito.when(mockProcess.getCurrentBreakpointList()).thenReturn(breakpoints);
    Mockito.when(mockProcess.getCurrentSnapshot()).thenReturn(bp1);
    CloudBreakpointHandler breakpointHandler = Mockito.mock(CloudBreakpointHandler.class);
    Mockito.when(mockProcess.getBreakpointHandler()).thenReturn(breakpointHandler);
    runModelSetter(snapshots);
    Assert.assertEquals(0, snapshots.table.getSelectedRow());
}
Also used : SourceLocation(com.google.api.services.clouddebugger.v2.model.SourceLocation) Breakpoint(com.google.api.services.clouddebugger.v2.model.Breakpoint) CloudBreakpointHandler(com.google.cloud.tools.intellij.debugger.CloudBreakpointHandler) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with CloudBreakpointHandler

use of com.google.cloud.tools.intellij.debugger.CloudBreakpointHandler in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudDebugHistoricalSnapshotsTest method testOnBreakpointListChanged_twoBreakPoints.

@Test
public void testOnBreakpointListChanged_twoBreakPoints() throws InterruptedException {
    CloudDebugHistoricalSnapshots snapshots = new CloudDebugHistoricalSnapshots(handler);
    Breakpoint bp1 = new Breakpoint();
    bp1.setId("bp1");
    bp1.setFinalTime("2015-08-22T05:23:34.123Z");
    bp1.setIsFinalState(true);
    SourceLocation location = new SourceLocation();
    location.setPath("foo/bar/baz");
    location.setLine(12);
    bp1.setLocation(location);
    Breakpoint bp2 = new Breakpoint();
    bp2.setId("bp2");
    bp2.setFinalTime("2016-08-22T05:23:34.123Z");
    bp2.setIsFinalState(true);
    SourceLocation location2 = new SourceLocation();
    location2.setPath("foo/bar/baz");
    location2.setLine(14);
    bp2.setLocation(location);
    List<Breakpoint> breakpoints1 = new ArrayList<Breakpoint>();
    breakpoints1.add(bp1);
    List<Breakpoint> breakpoints2 = new ArrayList<Breakpoint>();
    breakpoints2.add(bp1);
    breakpoints2.add(bp2);
    CloudBreakpointHandler breakpointHandler = Mockito.mock(CloudBreakpointHandler.class);
    Mockito.when(mockProcess.getBreakpointHandler()).thenReturn(breakpointHandler);
    Assert.assertEquals(-1, snapshots.table.getSelectedRow());
    // BP1
    Mockito.when(mockProcess.getCurrentBreakpointList()).thenReturn(breakpoints1);
    Mockito.when(mockProcess.getCurrentSnapshot()).thenReturn(bp1);
    runModelSetter(snapshots);
    Assert.assertEquals(0, snapshots.table.getSelectedRow());
    // BP2
    Mockito.when(mockProcess.getCurrentBreakpointList()).thenReturn(breakpoints2);
    Mockito.when(mockProcess.getCurrentSnapshot()).thenReturn(bp2);
    runModelSetter(snapshots);
    Assert.assertEquals(1, snapshots.table.getSelectedRow());
}
Also used : SourceLocation(com.google.api.services.clouddebugger.v2.model.SourceLocation) Breakpoint(com.google.api.services.clouddebugger.v2.model.Breakpoint) CloudBreakpointHandler(com.google.cloud.tools.intellij.debugger.CloudBreakpointHandler) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Breakpoint (com.google.api.services.clouddebugger.v2.model.Breakpoint)2 SourceLocation (com.google.api.services.clouddebugger.v2.model.SourceLocation)2 CloudBreakpointHandler (com.google.cloud.tools.intellij.debugger.CloudBreakpointHandler)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2