3 * Copyright (C) 2009-2016 SonarSource SA
4 * mailto:contact AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.computation.task.projectanalysis.step;
22 import com.google.common.collect.Lists;
23 import org.junit.Rule;
24 import org.junit.Test;
25 import org.junit.rules.ExpectedException;
26 import org.sonar.core.platform.ComponentContainer;
27 import org.sonar.core.platform.ContainerPopulator;
28 import org.sonar.server.computation.task.container.TaskContainer;
29 import org.sonar.server.computation.task.container.TaskContainerImpl;
31 import static org.mockito.Mockito.mock;
33 public class ReportComputationStepsTest {
35 public ExpectedException expectedException = ExpectedException.none();
38 public void instances_throws_ISE_if_container_does_not_have_any_step() throws Exception {
39 expectedException.expect(IllegalStateException.class);
40 expectedException.expectMessage("Component not found: " + ExtractReportStep.class);
42 TaskContainerImpl computeEngineContainer = new TaskContainerImpl(new ComponentContainer(), new ContainerPopulator<TaskContainer>() {
44 public void populateContainer(TaskContainer container) {
49 Lists.newArrayList(new ReportComputationSteps(computeEngineContainer).instances());
53 public void instances_throws_ISE_if_container_does_not_have_second_step() throws Exception {
54 expectedException.expect(IllegalStateException.class);
55 expectedException.expectMessage("Component not found: class org.sonar.server.computation.task.projectanalysis.step.GenerateAnalysisUuid");
57 final ExtractReportStep reportExtractionStep = mock(ExtractReportStep.class);
58 ComponentContainer componentContainer = new ComponentContainer() {
60 addSingleton(reportExtractionStep);
63 TaskContainerImpl computeEngineContainer = new TaskContainerImpl(componentContainer, new ContainerPopulator<TaskContainer>() {
65 public void populateContainer(TaskContainer container) {
70 Lists.newArrayList(new ReportComputationSteps(computeEngineContainer).instances());