3 * Copyright (C) 2009-2017 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.server.computation.task.projectanalysis.step;
22 import static org.mockito.Mockito.verify;
23 import static org.mockito.Mockito.verifyZeroInteractions;
25 import org.junit.Before;
26 import org.junit.Rule;
27 import org.junit.Test;
28 import org.mockito.Mock;
29 import org.mockito.MockitoAnnotations;
30 import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
31 import org.sonar.server.computation.task.projectanalysis.duplication.DuplicationMeasures;
32 import org.sonar.server.computation.task.projectanalysis.duplication.IncrementalDuplicationMeasures;
33 import org.sonar.server.computation.task.step.ComputationStep;
35 public class DuplicationMeasuresStepTest extends BaseStepTest {
37 private DuplicationMeasures defaultDuplicationMeasures;
39 private IncrementalDuplicationMeasures incrementalDuplicationMeasures;
41 public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule();
43 private DuplicationMeasuresStep underTest;
46 public void before() {
47 MockitoAnnotations.initMocks(this);
48 underTest = new DuplicationMeasuresStep(analysisMetadataHolder, defaultDuplicationMeasures, incrementalDuplicationMeasures);
52 public void incremental_analysis_mode() {
53 analysisMetadataHolder.setIncrementalAnalysis(true);
55 verify(incrementalDuplicationMeasures).execute();
56 verifyZeroInteractions(defaultDuplicationMeasures);
60 public void full_analysis_mode() {
61 analysisMetadataHolder.setIncrementalAnalysis(false);
63 verify(defaultDuplicationMeasures).execute();
64 verifyZeroInteractions(incrementalDuplicationMeasures);
68 protected ComputationStep step() {