]> source.dussan.org Git - sonarqube.git/blob
f8ff545f980ebef7915f7e6f054194bb5d25a1f3
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2016 SonarSource SA
4  * mailto:contact AT sonarsource DOT com
5  *
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.
10  *
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.
15  *
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.
19  */
20 package org.sonar.server.computation.task.projectanalysis.step;
21
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;
30
31 import static org.mockito.Mockito.mock;
32
33 public class ReportComputationStepsTest {
34   @Rule
35   public ExpectedException expectedException = ExpectedException.none();
36
37   @Test
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);
41
42     TaskContainerImpl computeEngineContainer = new TaskContainerImpl(new ComponentContainer(), new ContainerPopulator<TaskContainer>() {
43       @Override
44       public void populateContainer(TaskContainer container) {
45         // do nothing
46       }
47     });
48
49     Lists.newArrayList(new ReportComputationSteps(computeEngineContainer).instances());
50   }
51
52   @Test
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");
56
57     final ExtractReportStep reportExtractionStep = mock(ExtractReportStep.class);
58     ComponentContainer componentContainer = new ComponentContainer() {
59       {
60         addSingleton(reportExtractionStep);
61       }
62     };
63     TaskContainerImpl computeEngineContainer = new TaskContainerImpl(componentContainer, new ContainerPopulator<TaskContainer>() {
64       @Override
65       public void populateContainer(TaskContainer container) {
66         // do nothing
67       }
68     });
69
70     Lists.newArrayList(new ReportComputationSteps(computeEngineContainer).instances());
71   }
72 }