@Before public void setUp() throws Exception { super.setUp(); runner = SonarLintTestUtils.mockRunner(getProject()); action = new UpdateAction(); getProject().getComponent(SonarLintStatus.class).stopRun(); }
@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(); }
@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(); } }