3 * Copyright (C) 2009-2022 SonarSource SA
4 * mailto:info 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.ce.task.projectanalysis.step;
22 import org.junit.Test;
23 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
24 import org.sonar.ce.task.projectanalysis.view.TriggerViewRefreshDelegate;
25 import org.sonar.ce.task.step.TestComputationStepContext;
26 import org.sonar.server.project.Project;
28 import static org.mockito.Mockito.mock;
29 import static org.mockito.Mockito.verify;
30 import static org.mockito.Mockito.verifyZeroInteractions;
31 import static org.mockito.Mockito.when;
33 public class TriggerViewRefreshStepTest {
34 private AnalysisMetadataHolder analysisMetadataHolder = mock(AnalysisMetadataHolder.class);
37 public void execute_has_no_effect_if_constructor_without_delegate() {
38 TriggerViewRefreshStep underTest = new TriggerViewRefreshStep(analysisMetadataHolder);
40 underTest.execute(new TestComputationStepContext());
42 verifyZeroInteractions(analysisMetadataHolder);
46 public void execute_has_no_effect_if_constructor_with_null_delegate() {
47 TriggerViewRefreshStep underTest = new TriggerViewRefreshStep(analysisMetadataHolder);
49 underTest.execute(new TestComputationStepContext());
51 verifyZeroInteractions(analysisMetadataHolder);
55 public void execute_calls_delegate_with_project_from_holder_if_passed_to_constructor() {
56 TriggerViewRefreshDelegate delegate = mock(TriggerViewRefreshDelegate.class);
57 Project project = mock(Project.class);
58 when(analysisMetadataHolder.getProject()).thenReturn(project);
59 TriggerViewRefreshStep underTest = new TriggerViewRefreshStep(analysisMetadataHolder, new TriggerViewRefreshDelegate[]{delegate});
61 underTest.execute(new TestComputationStepContext());
63 verify(analysisMetadataHolder).getProject();
64 verify(delegate).triggerFrom(project);