Ejemplo n.º 1
0
  @Test
  public void testEnabled() {
    SonarLintStatus status = mock(SonarLintStatus.class);

    when(status.isRunning()).thenReturn(false);
    assertThat(action.isEnabled(status)).isTrue();

    when(status.isRunning()).thenReturn(true);
    assertThat(action.isEnabled(status)).isFalse();
  }
Ejemplo n.º 2
0
  @Test
  public void testAction() {
    action.actionPerformed(SonarLintTestUtils.createAnActionEvent(getProject()));

    verify(runner).tryUpdate();
    verify(runner).getVersion();
    verifyNoMoreInteractions(runner);

    SonarLintStatus status = getProject().getComponent(SonarLintStatus.class);
    assertThat(status.isRunning()).isFalse();
  }
Ejemplo n.º 3
0
 @Test
 public void testFailIfRunning() {
   SonarLintStatus status = getProject().getComponent(SonarLintStatus.class);
   status.tryRun();
   try {
     action.actionPerformed(SonarLintTestUtils.createAnActionEvent(getProject()));
     fail("Should throw exception");
   } catch (IllegalStateException e) {
     assertThat(e.getMessage()).isEqualTo("Unable to update SonarLint as an analysis is on-going");
   } finally {
     status.stopRun();
   }
 }
 @Override
 protected boolean isEnabled(SonarLintStatus status) {
   return !status.isRunning();
 }