use of com.google.api.services.clouddebugger.v2.model.SourceLocation 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;
}
use of com.google.api.services.clouddebugger.v2.model.SourceLocation in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudBreakpointHandlerTest method testConflictingRegister.
public void testConflictingRegister() {
Breakpoint existingServerBp = new Breakpoint();
SourceLocation location = new SourceLocation();
location.setPath("com/google/foo.java");
location.setLine(124);
existingServerBp.setLocation(location);
existingServerBp.setId("todelete");
existingBreakpoints.add(existingServerBp);
registerMockBreakpoint(new String[] { "foowatch1" }, "condition == true", 123, "foo.java", "com.google", false, "b_id");
existingBreakpoints.clear();
assertNotNull(addedBp.get());
assertContainsElements(addedBp.get().getExpressions(), "foowatch1");
assertTrue(addedBp.get().getLocation().getLine() == 124);
assertTrue(addedBp.get().getLocation().getPath().equals("com/google/foo.java"));
assertTrue(addedBp.get().getCondition().equals("condition == true"));
}
use of com.google.api.services.clouddebugger.v2.model.SourceLocation in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudBreakpointHandlerTest method testCreateIdeRepresentationsIfNecessary.
public void testCreateIdeRepresentationsIfNecessary() {
List<Breakpoint> breakpoints = ImmutableList.of(new Breakpoint().setId("expected_path").setLocation(new SourceLocation().setLine(1).setPath("app/mod/src/main/java/b/f/pkg/Class.java")), new Breakpoint().setId("unexpected_path").setLocation(new SourceLocation().setLine(2).setPath("app/mod/src/m/j/a/b/c/Class.java")), new Breakpoint().setId("unexpected_path_2").setLocation(new SourceLocation().setLine(3).setPath("b/f/pkg/Class.java")));
when(breakpointManager.findBreakpointAtLine(isA(XLineBreakpointType.class), isA(VirtualFile.class), anyInt())).thenReturn(null);
XLineBreakpoint mockLineBreakpoint = mock(XLineBreakpoint.class);
when(breakpointManager.addLineBreakpoint(isA(XLineBreakpointType.class), anyString(), anyInt(), isA(CloudLineBreakpointProperties.class))).thenReturn(mockLineBreakpoint);
when(mockLineBreakpoint.getProperties()).thenReturn(new CloudLineBreakpointProperties());
VirtualFile projectDir = mock(VirtualFile.class);
when(projectDir.getPath()).thenReturn("/project/dir");
project.setBaseDir(projectDir);
VirtualFile classFile = mock(VirtualFile.class);
when(classFile.getUrl()).thenReturn("file:///URL");
when(fileResolver.getFileFromPath(isA(Project.class), eq("app/mod/src/main/java/b/f/pkg/Class.java"))).thenReturn(classFile);
handler.createIdeRepresentationsIfNecessary(breakpoints);
verify(breakpointManager, times(1)).addLineBreakpoint(isA(XLineBreakpointType.class), anyString(), anyInt(), isA(XBreakpointProperties.class));
}
use of com.google.api.services.clouddebugger.v2.model.SourceLocation 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());
}
use of com.google.api.services.clouddebugger.v2.model.SourceLocation in project google-cloud-intellij by GoogleCloudPlatform.
the class BreakpointComparer method compare.
@SuppressWarnings("ConstantConditions")
@Override
public int compare(Breakpoint o1, Breakpoint o2) {
if (o2.getFinalTime() == null && o1.getFinalTime() != null) {
return 1;
}
if (o2.getFinalTime() != null && o1.getFinalTime() == null) {
return -1;
}
if (o2.getFinalTime() == null && o1.getFinalTime() == null) {
// compare file and line
SourceLocation s1 = o1.getLocation();
SourceLocation s2 = o2.getLocation();
boolean s1Valid = isSourceLocationValid(s1);
boolean s2Valid = isSourceLocationValid(s2);
if (!s1Valid && !s2Valid) {
return 0;
}
if (s1Valid && !s2Valid) {
return -1;
}
if (!s1Valid && s2Valid) {
return 1;
}
if (s1.getPath().equals(s2.getPath())) {
long s1Line = toLongValue(s1.getLine().longValue());
long s2Line = toLongValue(s2.getLine().longValue());
if (s1Line > s2Line) {
return 1;
}
if (s1Line < s2Line) {
return -1;
}
return 0;
}
return s1.getPath().compareTo(s2.getPath());
}
Date d1, d2;
try {
d1 = ISODateTimeFormat.dateTime().parseDateTime(o1.getFinalTime()).toDate();
d2 = ISODateTimeFormat.dateTime().parseDateTime(o2.getFinalTime()).toDate();
} catch (IllegalArgumentException iae) {
d1 = MINIMUM_DATE;
d2 = MINIMUM_DATE;
}
return d2.compareTo(d1);
}
Aggregations