@Test public void throw_exception_if_run_fails() { thrown.expect(BuildFailureException.class); thrown.expectMessage("statuses=[2]"); Build build = mock(Build.class); try { Configuration config = Configuration.create(); Server server = mock(Server.class); when(server.version()).thenReturn(Version.create("5.6")); when(build.execute(any(Configuration.class), anyMap())).thenReturn(new BuildResult().addStatus(2)); BuildRunner runner = new BuildRunner(config); runner.run(server, build); } catch (BuildFailureException e) { assertThat(e.getBuild()).isEqualTo(build); assertThat(e.getResult().isSuccess()).isFalse(); assertThat(e.getResult().isSuccess()).isFalse(); assertThat(e.getMessage()).startsWith("statuses=[2]"); throw e; } }
public BuildResult run(@Nullable Server server, Build<?> build) { BuildResult result = runQuietly(server, build); if (!result.isSuccess()) { throw new BuildFailureException(build, result); } return result; }
BuildRunner { public BuildResult run(@Nullable Server server, Build<?> build) { BuildResult result = runQuietly(server, build); if (!result.isSuccess()) { throw new BuildFailureException(build, result); } return result; } }
BuildRunner { public BuildResult run(@Nullable Server server, Build<?> build) { BuildResult result = runQuietly(server, build); if (!result.isSuccess()) { throw new BuildFailureException(build, result); } return result; } BuildRunner(Configuration config); }
BuildRunner { public BuildResult run(@Nullable Server server, Build<?> build) { BuildResult result = runQuietly(server, build); if (!result.isSuccess()) { throw new BuildFailureException(build, result); } return result; } BuildRunner(Configuration config); BuildResult runQuietly(@Nullable Server server, Build<?> build); BuildResult run(@Nullable Server server, Build<?> build); }
BuildRunner { public BuildResult run(@Nullable Server server, Build<?> build) { BuildResult result = runQuietly(server, build); if (!result.isSuccess()) { throw new BuildFailureException(build, result); } return result; } BuildRunner(Configuration config); BuildResult runQuietly(@Nullable Server server, Build<?> build); BuildResult run(@Nullable Server server, Build<?> build); static final String SONAR_HOST_URL; }