verify(cloudLineBreakpoint).setErrorMessage(eq(breakPointErrorMessage)); verify(process, times(1)).getXBreakpoint(cloudLineBreakpoint); verify(cloudLineBreakpoint).getSetIcon(anyBoolean()); verify(cloudLineBreakpoint).getErrorMessage(); verify(breakpointManager) .updateBreakpointPresentation(
@NotNull @Override public Breakpoint createJavaBreakpoint(Project project, XBreakpoint breakpoint) { CloudLineBreakpoint lineBreakpoint = new CloudLineBreakpoint(project, breakpoint); lineBreakpoint.init(); return lineBreakpoint; }
/** Get the watch expressions from the breakpoint. */ @Nullable public List<String> getWatchExpressions() { CloudLineBreakpointProperties properties = (CloudLineBreakpointProperties) getXBreakpoint().getProperties(); if (properties.getWatchExpressions() != null && properties.getWatchExpressions().length > 0) { return Arrays.asList(properties.getWatchExpressions()); } return null; }
List<String> watches = cloudIdeLineBreakpoint.getWatchExpressions(); if (watches != null) { serverNewBreakpoint.setExpressions(watches);
CloudLineBreakpointType.CloudLineBreakpoint cloudIdeLineBreakpoint = (CloudLineBreakpointType.CloudLineBreakpoint) cloudIdeBreakpoint; cloudIdeLineBreakpoint.setVerified(true); cloudIdeLineBreakpoint.setErrorMessage(null); process.updateBreakpointPresentation(cloudIdeLineBreakpoint);
cloudLineBreakpointType.getEditorsProvider(breakpoint, cloudBreakpoint.getProject()); cloudBreakpoint.getProject(), debuggerEditorsProvider, this,
&& cloudBreakpoint instanceof CloudLineBreakpointType.CloudLineBreakpoint) { CloudLineBreakpoint cloudLineBreakpoint = (CloudLineBreakpoint) cloudBreakpoint; cloudLineBreakpoint.setErrorMessage( BreakpointUtil.getUserErrorMessage(breakpoint.getStatus())); updateBreakpointPresentation(cloudLineBreakpoint);
CloudLineBreakpointType.CloudLineBreakpoint cloudIdeLineBreakpoint = (CloudLineBreakpointType.CloudLineBreakpoint) cloudIdeBreakpoint; cloudIdeLineBreakpoint.setVerified(true); cloudIdeLineBreakpoint.setErrorMessage(null); debugProcess.updateBreakpointPresentation(cloudIdeLineBreakpoint);
@Override public void stop() { getStateController().stopBackgroundListening(); RunProfile profile = getXDebugSession().getRunProfile(); if (profile instanceof CloudDebugRunConfiguration) { ((CloudDebugRunConfiguration) profile).setProcessState(processState); } getRepositoryValidator().restoreToOriginalState(getXDebugSession().getProject()); XBreakpointManager breakpointManager = XDebuggerManager.getInstance(getXDebugSession().getProject()).getBreakpointManager(); for (XBreakpoint bp : breakpointManager.getAllBreakpoints()) { com.intellij.debugger.ui.breakpoints.Breakpoint cloudBreakpoint = BreakpointManager.getJavaBreakpoint(bp); if (!(cloudBreakpoint instanceof CloudLineBreakpointType.CloudLineBreakpoint)) { continue; } CloudLineBreakpointType.CloudLineBreakpoint cloudLineBreakpoint = (CloudLineBreakpointType.CloudLineBreakpoint) cloudBreakpoint; cloudLineBreakpoint.setVerified(false); cloudLineBreakpoint.setErrorMessage(null); updateBreakpointPresentation(cloudLineBreakpoint); } }
public void testSimpleKotlinFileBreakpointRegister() { KtFile ktFile = mock(KtFile.class); when(ktFile.getFileType()).thenReturn(KotlinFileType.INSTANCE); registerMockBreakpoint( ktFile, new String[] {"foowatch1"}, "condition == true", 123, "foo.java", "com.google", false, "b_id"); assertNull(removedBp.get()); 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")); ArgumentCaptor<CloudLineBreakpoint> breakpointArgumentCaptor = ArgumentCaptor.forClass(CloudLineBreakpoint.class); verify(process).updateBreakpointPresentation(breakpointArgumentCaptor.capture()); assertThat(breakpointArgumentCaptor.getValue().getErrorMessage(), nullValue()); }
public void testSimpleJavaFileBreakpointRegister() { registerMockBreakpoint( psiJavaFile, new String[] {"foowatch1"}, "condition == true", 123, "foo.java", "com.google", false, "b_id"); assertNull(removedBp.get()); 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")); ArgumentCaptor<CloudLineBreakpoint> breakpointArgumentCaptor = ArgumentCaptor.forClass(CloudLineBreakpoint.class); verify(process).updateBreakpointPresentation(breakpointArgumentCaptor.capture()); assertThat(breakpointArgumentCaptor.getValue().getErrorMessage(), nullValue()); }
@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()); } }
public void testRegisterBreakpointErrorShouldSetErrorMessageAndCallUpdateBreakpointPresentation2() { registerMockBreakpoint( psiJavaFile, new String[] {"foowatch1"}, "condition == true", 123, "foo.java", "com.google", false, ""); ArgumentCaptor<CloudLineBreakpoint> breakpointArgumentCaptor = ArgumentCaptor.forClass(CloudLineBreakpoint.class); verify(process).updateBreakpointPresentation(breakpointArgumentCaptor.capture()); assertThat( breakpointArgumentCaptor.getValue().getErrorMessage(), equalTo("The snapshot location could not be set.")); }
public void testRegisterBreakpointErrorShouldSetErrorMessageAndCallUpdateBreakpointPresentation() { registrationShouldSucceed = false; registerMockBreakpoint( psiJavaFile, new String[] {"foowatch1"}, "condition == true", 123, "foo.java", "com.google", false, "b_id"); ArgumentCaptor<CloudLineBreakpoint> breakpointArgumentCaptor = ArgumentCaptor.forClass(CloudLineBreakpoint.class); verify(process).updateBreakpointPresentation(breakpointArgumentCaptor.capture()); assertThat( breakpointArgumentCaptor.getValue().getErrorMessage(), equalTo("Registration failed")); }
@Test public void testUpdateBreakpointRepresentationUsesBreakpointErrorMsgAndIcon() { XBreakpointManager breakpointManager = mock(XBreakpointManager.class); CloudDebugProcess cloudDebugProcess = mockCloudDebugProcess(breakpointManager, mock(XDebugSession.class)); XLineBreakpointImpl xBreakpoint = mock(XLineBreakpointImpl.class); CloudLineBreakpoint breakpoint = mockCloudLineBreakpoint(cloudDebugProcess, "mock error message", xBreakpoint); Icon icon = mock(Icon.class); when(breakpoint.getSetIcon(anyBoolean())).thenReturn(icon); cloudDebugProcess.updateBreakpointPresentation(breakpoint); verify(cloudDebugProcess, times(1)).getXBreakpoint(breakpoint); verify(breakpoint).getSetIcon(anyBoolean()); verify(breakpoint).getErrorMessage(); verify(breakpointManager).updateBreakpointPresentation(xBreakpoint, icon, "mock error message"); }
public void testCreateIdeRepresentationsIfNecessaryVerifiesNonFinalIdeBreakpoint() throws Exception { XLineBreakpointImpl breakpoint = registerMockBreakpoint( psiJavaFile, NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc"); CloudLineBreakpoint cloudLineBreakpoint = (CloudLineBreakpoint) breakpoint.getUserData(com.intellij.debugger.ui.breakpoints.Breakpoint.DATA_KEY); assertNotNull(cloudLineBreakpoint); Assert.assertFalse(cloudLineBreakpoint.isVerified()); handler.createIdeRepresentationsIfNecessary( Lists.newArrayList(new Breakpoint().setId("12abc"))); assertThat(cloudLineBreakpoint.getErrorMessage(), nullValue()); Assert.assertTrue(cloudLineBreakpoint.isVerified()); }
public boolean hasError() { return !Strings.isNullOrEmpty(getErrorMessage()); }
@Override public void onError(String errorMessage) { cloudIdeLineBreakpoint.setErrorMessage(errorMessage); process.updateBreakpointPresentation(cloudIdeLineBreakpoint); } });
private void verifyMutedIconSettingInUpdateBreakpointPresentation(Boolean muted) { XBreakpointManager breakpointManager = mock(XBreakpointManager.class); XDebugSession debugSession = mock(XDebugSession.class); when(debugSession.areBreakpointsMuted()).thenReturn(muted); CloudDebugProcess cloudDebugProcess = mockCloudDebugProcess(breakpointManager, debugSession); CloudLineBreakpoint breakpoint = mockCloudLineBreakpoint( cloudDebugProcess, "mock error message", mock(XLineBreakpointImpl.class)); cloudDebugProcess.updateBreakpointPresentation(breakpoint); verify(breakpoint).getSetIcon(muted); }
@NotNull // mock behavior except for get/setErrorMessage() to simplify code private CloudLineBreakpoint mockCloudLineBreakpoint( CloudDebugProcess spyDebugProcess, String errorMessage, XLineBreakpointImpl xLineBreakpoint) { CloudLineBreakpoint breakpoint = mock(CloudLineBreakpoint.class); when(breakpoint.getSetIcon(anyBoolean())).thenReturn(mock(Icon.class)); doAnswer(invocationOnMock -> xLineBreakpoint).when(spyDebugProcess).getXBreakpoint(any()); when(breakpoint.getErrorMessage()).thenReturn(errorMessage); return breakpoint; } }