public void testServerCreation() { registerMockBreakpoint( psiJavaFile, new String[] {"foowatch1"}, "condition == true", 123, "foo.java", "com.google", true, "b_id"); assertNull(addedBp.get()); }
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")); }
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 testRegisterRegisteredBreakpoint() { XLineBreakpointImpl<CloudLineBreakpointProperties> breakpoint = registerMockBreakpoint( psiJavaFile, NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc"); handler.registerBreakpoint(breakpoint); verify(stateController, times(1)) .setBreakpointAsync(isA(Breakpoint.class), isA(SetBreakpointHandler.class)); }
public void testRegisterRegisteredButDisabledBreakpoint() { XLineBreakpointImpl<CloudLineBreakpointProperties> breakpoint = registerMockBreakpoint( psiJavaFile, NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc"); handler.setStateToDisabled(new Breakpoint().setId("12abc")); handler.registerBreakpoint(breakpoint); verify(stateController, times(2)) .setBreakpointAsync(isA(Breakpoint.class), isA(SetBreakpointHandler.class)); }
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()); }
@SuppressWarnings("unchecked") public void testUnregisterBreakpoint_shouldSetAddedOnServerToFalseAfterClientDisablesBp() throws Exception { XLineBreakpointImpl breakpoint = registerMockBreakpoint( psiJavaFile, NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc"); assertNotNull(breakpoint.getProperties()); assertTrue(((CloudLineBreakpointProperties) breakpoint.getProperties()).isAddedOnServer()); handler.unregisterBreakpoint(breakpoint, false); assertFalse(((CloudLineBreakpointProperties) breakpoint.getProperties()).isAddedOnServer()); verify(stateController).deleteBreakpointAsync("12abc"); }
@SuppressWarnings("unchecked") public void testUnregisterBreakpoint_shouldSetAddedOnServerToFalseAfterHitOnBackend() throws Exception { XLineBreakpointImpl breakpoint = registerMockBreakpoint( psiJavaFile, NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc"); handler.setStateToDisabled(new Breakpoint().setId("12abc")); assertNotNull(breakpoint.getProperties()); assertTrue(((CloudLineBreakpointProperties) breakpoint.getProperties()).isAddedOnServer()); handler.unregisterBreakpoint(breakpoint, false); assertFalse(((CloudLineBreakpointProperties) breakpoint.getProperties()).isAddedOnServer()); verify(stateController, never()).deleteBreakpointAsync("12abc"); }
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()); }
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 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( psiJavaFile, 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")); }
public void testRegisterGetAndDelete() { 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")); addedBp.get().setId("b_id"); XBreakpoint xideBreakpoint = handler.getXBreakpoint(addedBp.get()); assertNotNull(xideBreakpoint); handler.deleteBreakpoint(addedBp.get()); assertNotNull(removedBp.get()); assertTrue(removedBp.get().equals(addedBp.get().getId())); }