@Test public void testGetTopFrame_nullFramesReturnsNull() { CloudExecutionStack stack = new CloudExecutionStack(project, "name", null, null, null); Assert.assertNull(stack.getTopFrame()); }
private void navigateToBreakpoint(@NotNull Breakpoint target) { Date snapshotTime; try { if (target.getFinalTime() == null) { LOG.warn("Could not resolve final time from breakpoint."); snapshotTime = new Date(); } else { snapshotTime = ISODateTimeFormat.dateTime().parseDateTime(target.getFinalTime()).toDate(); } } catch (IllegalArgumentException iae) { LOG.warn("Could not parse breakpoint timestamp using ISO8601."); snapshotTime = new Date(); } DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); currentSnapshot = target; if (!getXDebugSession().isStopped()) { getXDebugSession() .positionReached( new MySuspendContext( new CloudExecutionStack( getXDebugSession().getProject(), StackdriverDebuggerBundle.getString( "clouddebug.stackat", df.format(snapshotTime)), target.getStackFrames(), target.getVariableTable(), target.getEvaluatedExpressions()))); } }
@Test public void testGetTopFrame_nonNull() { List<StackFrame> frames = new ArrayList<StackFrame>(); StackFrame frame1 = new StackFrame(); SourceLocation location1 = new SourceLocation(); location1.setLine(1); frame1.setLocation(location1); List<Variable> variables = new ArrayList<Variable>(); Variable variable = new Variable(); variable.setName("foo"); variables.add(variable); frame1.setLocals(variables); StackFrame frame2 = new StackFrame(); SourceLocation location2 = new SourceLocation(); location2.setLine(2); frame2.setLocation(location2); frames.add(frame1); frames.add(frame2); CloudExecutionStack stack = new CloudExecutionStack(project, "name", frames, null, null); CloudStackFrame localFrame = stack.getTopFrame(); Assert.assertNotNull(localFrame); SpyNode node = new SpyNode(); localFrame.computeChildren(node); Assert.assertEquals(1, node.seenChildren.size()); Assert.assertEquals("foo", node.seenChildren.get(0)); }