.build();
@Before
- public void cleanUp() throws Exception {
+ public void cleanUp() {
orchestrator.resetData();
}
.build();
@Before
- public void cleanUp() throws Exception {
+ public void cleanUp() {
orchestrator.resetData();
provisionnedProjectId = Long.parseLong(orchestrator.getServer().adminWsClient().projectClient().create(NewProject.create().key(PROJECT_KEY).name("Sample")).id());
}
scrollRows();
}
- private void scrollRows() throws Exception {
+ private void scrollRows() {
LOGGER.info("Scroll table FILE_SOURCES");
AtomicLong counter = new AtomicLong();
ProgressTask progress = new ProgressTask(LOGGER, "source file", counter);
public DbTester dbTester = DbTester.create(System2.INSTANCE);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
}
public class BatchWsModuleTest {
@Test
- public void verify_count_of_added_components() throws Exception {
+ public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new BatchWsModule().configure(container);
assertThat(container.size()).isEqualTo(10);
}
@Test
- public void select_ghost_projects() throws Exception {
+ public void select_ghost_projects() {
db.prepareDbUnit(getClass(), "select_ghost_projects.xml");
List<ComponentDto> result = sut.selectGhostProjects(session, null, new SearchOptions());
ComputationService sut;
@Before
- public void setUp() throws IOException {
+ public void setUp() {
sut = new ComputationService(new ReportQueue.Item(dto, new File("Do_not_care")), steps, activityManager, system);
}
@Test
- public void process_new_project() throws Exception {
+ public void process_new_project() {
logTester.setLevel(LoggerLevel.INFO);
when(steps.instances()).thenReturn(Arrays.asList(projectStep1, projectStep2));
}
@Test
- public void debug_logs() throws Exception {
+ public void debug_logs() {
when(steps.instances()).thenReturn(Collections.<ComputationStep>emptyList());
logTester.setLevel(LoggerLevel.DEBUG);
}
@Test
- public void fail_if_step_throws_error() throws Exception {
+ public void fail_if_step_throws_error() {
String errorMessage = "Failed to unzip";
when(steps.instances()).thenReturn(ImmutableList.of(projectStep1));
doThrow(new IllegalStateException(errorMessage)).when(projectStep1).execute();
}
@Test
- public void step_error() throws Exception {
+ public void step_error() {
when(steps.instances()).thenReturn(Arrays.asList(projectStep1));
doThrow(new IllegalStateException("pb")).when(projectStep1).execute();
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
session.close();
}
ActivityManager underTest;
@Before
- public void setup() throws Exception {
+ public void setup() {
dbTester.truncateTables();
DbClient dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new ComponentDao());
}
@Test
- public void process_existing_project() throws Exception {
+ public void process_existing_project() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
underTest.saveActivity(reportDto);
}
@Test
- public void process_new_project() throws Exception {
+ public void process_new_project() {
underTest.saveActivity(reportDto);
// execute only the steps supporting the project qualifier
private FileStructure fileStructure;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
BatchReportDirectoryHolder holder = new ImmutableBatchReportDirectoryHolder(tempFolder.newDir());
underTest = new BatchReportReaderImpl(holder);
writer = new BatchReportWriter(holder.getDirectory());
}
@Test
- public void verify_readTests() throws IOException {
+ public void verify_readTests() {
writer.writeTests(COMPONENT_REF, of(TEST_1, TEST_2));
CloseableIterator<BatchReport.Test> res = underTest.readTests(COMPONENT_REF);
}
@Test
- public void verify_readCoverageDetails() throws IOException {
+ public void verify_readCoverageDetails() {
writer.writeCoverageDetails(COMPONENT_REF, of(COVERAGE_DETAIL_1, COVERAGE_DETAIL_2));
CloseableIterator<BatchReport.CoverageDetail> res = underTest.readCoverageDetails(COMPONENT_REF);
}
@Test
- public void get_name_from_batch_component() throws Exception {
+ public void get_name_from_batch_component() {
String name = "project";
ComponentImpl component = new ComponentImpl(BatchReport.Component.newBuilder().setName(name).build(), EMPTY_CHILD_LIST);
assertThat(component.getName()).isEqualTo(name);
}
@Test
- public void get_version_from_batch_component() throws Exception {
+ public void get_version_from_batch_component() {
String version = "1.0";
ComponentImpl component = new ComponentImpl(BatchReport.Component.newBuilder().setVersion(version).build(), EMPTY_CHILD_LIST);
assertThat(component.getVersion()).isEqualTo(version);
}
@Test
- public void getFileAttributes_throws_ISE_if_BatchComponent_does_not_have_type_FILE() throws Exception {
+ public void getFileAttributes_throws_ISE_if_BatchComponent_does_not_have_type_FILE() {
for (ComponentType componentType : from(asList(ComponentType.values())).filter(not(equalTo(ComponentType.FILE)))) {
ComponentImpl component = new ComponentImpl(BatchReport.Component.newBuilder().setType(componentType).build(), EMPTY_CHILD_LIST);
try {
}
@Test
- public void isUnitTest_returns_true_if_IsTest_is_set_in_BatchComponent() throws Exception {
+ public void isUnitTest_returns_true_if_IsTest_is_set_in_BatchComponent() {
ComponentImpl component = new ComponentImpl(BatchReport.Component.newBuilder().setType(ComponentType.FILE).setIsTest(true).build(), EMPTY_CHILD_LIST);
assertThat(component.getFileAttributes().isUnitTest()).isTrue();
}
@Test
- public void isUnitTest_returns_value_of_language_of_BatchComponent() throws Exception {
+ public void isUnitTest_returns_value_of_language_of_BatchComponent() {
String languageKey = "some language key";
ComponentImpl component = new ComponentImpl(BatchReport.Component.newBuilder().setType(ComponentType.FILE).setLanguage(languageKey).build(), EMPTY_CHILD_LIST);
public class ComponentTest {
@Test
- public void verify_type_is_deeper_than_when_comparing_to_itself() throws Exception {
+ public void verify_type_is_deeper_than_when_comparing_to_itself() {
for (Component.Type type : Component.Type.values()) {
assertThat(type.isDeeperThan(type)).isFalse();
}
}
@Test
- public void FILE_type_is_deeper_than_all_other_types() throws Exception {
+ public void FILE_type_is_deeper_than_all_other_types() {
assertThat(Component.Type.FILE.isDeeperThan(DIRECTORY)).isTrue();
assertThat(Component.Type.FILE.isDeeperThan(MODULE)).isTrue();
assertThat(Component.Type.FILE.isDeeperThan(PROJECT)).isTrue();
}
@Test
- public void DIRECTORY_type_is_deeper_than_MODULE_and_PROJECT() throws Exception {
+ public void DIRECTORY_type_is_deeper_than_MODULE_and_PROJECT() {
assertThat(Component.Type.DIRECTORY.isDeeperThan(MODULE)).isTrue();
assertThat(Component.Type.DIRECTORY.isDeeperThan(PROJECT)).isTrue();
}
@Test
- public void MODULE_type_is_deeper_than_PROJECT() throws Exception {
+ public void MODULE_type_is_deeper_than_PROJECT() {
assertThat(Component.Type.MODULE.isDeeperThan(PROJECT)).isTrue();
}
@Test
- public void FILE_type_is_higher_than_no_other_types() throws Exception {
+ public void FILE_type_is_higher_than_no_other_types() {
assertThat(Component.Type.FILE.isHigherThan(DIRECTORY)).isFalse();
assertThat(Component.Type.FILE.isHigherThan(MODULE)).isFalse();
assertThat(Component.Type.FILE.isHigherThan(PROJECT)).isFalse();
}
@Test
- public void DIRECTORY_type_is_higher_than_FILE() throws Exception {
+ public void DIRECTORY_type_is_higher_than_FILE() {
assertThat(Component.Type.DIRECTORY.isHigherThan(FILE)).isTrue();
}
@Test
- public void MODULE_type_is_higher_than_FILE_AND_DIRECTORY() throws Exception {
+ public void MODULE_type_is_higher_than_FILE_AND_DIRECTORY() {
assertThat(Component.Type.MODULE.isHigherThan(FILE)).isTrue();
assertThat(Component.Type.MODULE.isHigherThan(DIRECTORY)).isTrue();
}
@Test
- public void PROJECT_type_is_higher_than_all_other_types() throws Exception {
+ public void PROJECT_type_is_higher_than_all_other_types() {
assertThat(Component.Type.PROJECT.isHigherThan(FILE)).isTrue();
assertThat(Component.Type.PROJECT.isHigherThan(DIRECTORY)).isTrue();
assertThat(Component.Type.PROJECT.isHigherThan(MODULE)).isTrue();
}
@Test
- public void any_type_is_not_higher_than_itself() throws Exception {
+ public void any_type_is_not_higher_than_itself() {
assertThat(Component.Type.FILE.isHigherThan(FILE)).isFalse();
assertThat(Component.Type.DIRECTORY.isHigherThan(DIRECTORY)).isFalse();
assertThat(Component.Type.MODULE.isHigherThan(MODULE)).isFalse();
Component component = DumbComponent.DUMB_PROJECT;
@Test
- public void add_and_get_component_id() throws Exception {
+ public void add_and_get_component_id() {
DbIdsRepository cache = new DbIdsRepository();
cache.setComponentId(component, 10L);
}
@Test
- public void fail_to_get_component_id_on_unknown_ref() throws Exception {
+ public void fail_to_get_component_id_on_unknown_ref() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Component ref '" + component.getRef() + "' has no component id");
}
@Test
- public void fail_if_component_id_already_set() throws Exception {
+ public void fail_if_component_id_already_set() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Component ref '" + component.getRef() + "' has already a component id");
}
@Test
- public void add_and_get_snapshot_id() throws Exception {
+ public void add_and_get_snapshot_id() {
DbIdsRepository cache = new DbIdsRepository();
cache.setSnapshotId(component, 100L);
}
@Test
- public void fail_to_get_snapshot_id_on_unknown_ref() throws Exception {
+ public void fail_to_get_snapshot_id_on_unknown_ref() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Component ref '" + component.getRef() + "' has no snapshot id");
}
@Test
- public void fail_if_snapshot_id_already_set() throws Exception {
+ public void fail_if_snapshot_id_already_set() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Component ref '" + component.getRef() + "' has already a snapshot id");
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
session.close();
}
@Test
- public void get_project_settings_from_global_settings() throws Exception {
+ public void get_project_settings_from_global_settings() {
globalSettings.setProperty("key", "value");
Settings settings = sut.getProjectSettings(PROJECT_KEY);
}
@Test
- public void get_project_settings_from_db() throws Exception {
+ public void get_project_settings_from_db() {
ComponentDto project = ComponentTesting.newProjectDto().setKey(PROJECT_KEY);
dbClient.componentDao().insert(session, project);
dbClient.propertiesDao().setProperty(new PropertyDto().setResourceId(project.getId()).setKey("key").setValue("value"), session);
}
@Test
- public void call_twice_get_project_settings() throws Exception {
+ public void call_twice_get_project_settings() {
globalSettings.setProperty("key", "value");
Settings settings = sut.getProjectSettings(PROJECT_KEY);
}
@Test
- public void get_by_ref() throws Exception {
+ public void get_by_ref() {
Component file = DumbComponent.builder(Component.Type.FILE, 4).build();
Component directory = DumbComponent.builder(Component.Type.DIRECTORY, 3).addChildren(file).build();
Component module = DumbComponent.builder(Component.Type.MODULE, 2).addChildren(directory).build();
}
@Test
- public void fail_to_get_by_ref_if_root_not_set() throws Exception {
+ public void fail_to_get_by_ref_if_root_not_set() {
thrown.expect(IllegalStateException.class);
treeRootHolder.getComponentByRef(project.getRef());
}
@Test
- public void fail_to_get_by_ref_if_ref_not_found() throws Exception {
+ public void fail_to_get_by_ref_if_ref_not_found() {
thrown.expect(IllegalArgumentException.class);
treeRootHolder.setRoot(project);
treeRootHolder.getComponentByRef(123);
}
@Test
- public void creating_a_new_characteristic_with_null_key_throws_a_NPE() throws Exception {
+ public void creating_a_new_characteristic_with_null_key_throws_a_NPE() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("key cannot be null");
DebtModelHolderImpl sut = new DebtModelHolderImpl();
@Test
- public void add_and_get_characteristics() throws Exception {
+ public void add_and_get_characteristics() {
sut.addCharacteristics(PORTABILITY, Arrays.asList(COMPILER_RELATED_PORTABILITY, HARDWARE_RELATED_PORTABILITY));
sut.addCharacteristics(MAINTAINABILITY, singletonList(READABILITY));
}
@Test
- public void add_characteristics_fail_with_NPE_if_root_characteristic_is_null() throws Exception {
+ public void add_characteristics_fail_with_NPE_if_root_characteristic_is_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("rootCharacteristic cannot be null");
}
@Test
- public void add_characteristics_fail_with_NPE_if_sub_characteristics_are_null() throws Exception {
+ public void add_characteristics_fail_with_NPE_if_sub_characteristics_are_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("subCharacteristics cannot be null");
}
@Test
- public void add_characteristics_fail_with_IAE_if_sub_characteristics_are_empty() throws Exception {
+ public void add_characteristics_fail_with_IAE_if_sub_characteristics_are_empty() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("subCharacteristics cannot be empty");
}
@Test
- public void get_root_characteristics() throws Exception {
+ public void get_root_characteristics() {
sut.addCharacteristics(PORTABILITY, Arrays.asList(COMPILER_RELATED_PORTABILITY, READABILITY));
sut.addCharacteristics(MAINTAINABILITY, singletonList(READABILITY));
}
@Test
- public void getCharacteristicById_throws_ISE_when_not_initialized() throws Exception {
+ public void getCharacteristicById_throws_ISE_when_not_initialized() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Characteristics have not been initialized yet");
}
@Test
- public void getRootCharacteristics_throws_ISE_when_not_initialized() throws Exception {
+ public void getRootCharacteristics_throws_ISE_when_not_initialized() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Characteristics have not been initialized yet");
ComputeFormulaMeasuresStep sut;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
FormulaRepository formulaRepository = mock(FormulaRepository.class);
when(formulaRepository.getFormulas()).thenReturn(Lists.<Formula>newArrayList(
AverageFormula.Builder.newBuilder()
}
@Test
- public void add_measures() throws Exception {
+ public void add_measures() {
DumbComponent project = builder(PROJECT, 1)
.addChildren(
builder(MODULE, 11)
public ExpectedException thrown = ExpectedException.none();
@Test
- public void fail_with_NPE_when_building_formula_without_output_metric() throws Exception {
+ public void fail_with_NPE_when_building_formula_without_output_metric() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Output metric key cannot be null");
}
@Test
- public void fail_with_NPE_when_building_formula_without_main_metric() throws Exception {
+ public void fail_with_NPE_when_building_formula_without_main_metric() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Main metric Key cannot be null");
}
@Test
- public void fail_with_NPE_when_building_formula_without_by_metric() throws Exception {
+ public void fail_with_NPE_when_building_formula_without_by_metric() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("By metric Key cannot be null");
}
@Test
- public void check_new_counter_class() throws Exception {
+ public void check_new_counter_class() {
assertThat(BASIC_AVERAGE_FORMULA.createNewCounter().getClass()).isEqualTo(AverageFormula.AverageCounter.class);
}
@Test
- public void check_output_metric_key_is_function_complexity_key() throws Exception {
+ public void check_output_metric_key_is_function_complexity_key() {
assertThat(BASIC_AVERAGE_FORMULA.getOutputMetricKey()).isEqualTo(FUNCTION_COMPLEXITY_KEY);
}
@Test
- public void create_measure_when_counter_is_aggregated_from_context() throws Exception {
+ public void create_measure_when_counter_is_aggregated_from_context() {
AverageFormula.AverageCounter counter = BASIC_AVERAGE_FORMULA.createNewCounter();
addMeasure(COMPLEXITY_IN_FUNCTIONS_KEY, 10d);
addMeasure(FUNCTIONS_KEY, 2d);
}
@Test
- public void create_measure_when_counter_is_aggregated_from_another_counter() throws Exception {
+ public void create_measure_when_counter_is_aggregated_from_another_counter() {
AverageFormula.AverageCounter anotherCounter = BASIC_AVERAGE_FORMULA.createNewCounter();
addMeasure(COMPLEXITY_IN_FUNCTIONS_KEY, 10d);
addMeasure(FUNCTIONS_KEY, 2d);
}
@Test
- public void create_double_measure() throws Exception {
+ public void create_double_measure() {
AverageFormula.AverageCounter counter = BASIC_AVERAGE_FORMULA.createNewCounter();
addMeasure(COMPLEXITY_IN_FUNCTIONS_KEY, 10d);
addMeasure(FUNCTIONS_KEY, 2d);
}
@Test
- public void create_integer_measure() throws Exception {
+ public void create_integer_measure() {
AverageFormula.AverageCounter counter = BASIC_AVERAGE_FORMULA.createNewCounter();
addMeasure(COMPLEXITY_IN_FUNCTIONS_KEY, 10);
addMeasure(FUNCTIONS_KEY, 2);
}
@Test
- public void create_long_measure() throws Exception {
+ public void create_long_measure() {
AverageFormula.AverageCounter counter = BASIC_AVERAGE_FORMULA.createNewCounter();
addMeasure(COMPLEXITY_IN_FUNCTIONS_KEY, 10L);
addMeasure(FUNCTIONS_KEY, 2L);
}
@Test
- public void not_create_measure_when_aggregated_measure_has_no_value() throws Exception {
+ public void not_create_measure_when_aggregated_measure_has_no_value() {
AverageFormula.AverageCounter counter = BASIC_AVERAGE_FORMULA.createNewCounter();
addMeasure(COMPLEXITY_IN_FUNCTIONS_KEY, 10L);
when(counterContext.getMeasure(FUNCTIONS_KEY)).thenReturn(Optional.of(Measure.newMeasureBuilder().createNoValue()));
}
@Test
- public void fail_with_IAE_when_aggregate_from_component_and_context_with_not_numeric_measures() throws Exception {
+ public void fail_with_IAE_when_aggregate_from_component_and_context_with_not_numeric_measures() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Measure of type 'STRING' are not supported");
}
@Test
- public void no_measure_created_when_counter_has_no_value() throws Exception {
+ public void no_measure_created_when_counter_has_no_value() {
AverageFormula.AverageCounter counter = BASIC_AVERAGE_FORMULA.createNewCounter();
when(counterContext.getMeasure(anyString())).thenReturn(Optional.<Measure>absent());
counter.aggregate(counterContext);
}
@Test
- public void not_create_measure_when_only_one_measure() throws Exception {
+ public void not_create_measure_when_only_one_measure() {
AverageFormula.AverageCounter counter = BASIC_AVERAGE_FORMULA.createNewCounter();
addMeasure(COMPLEXITY_IN_FUNCTIONS_KEY, 10L);
when(counterContext.getMeasure(FUNCTIONS_KEY)).thenReturn(Optional.<Measure>absent());
}
@Test
- public void not_create_measure_when_by_value_is_zero() throws Exception {
+ public void not_create_measure_when_by_value_is_zero() {
AverageFormula.AverageCounter counter = BASIC_AVERAGE_FORMULA.createNewCounter();
addMeasure(COMPLEXITY_IN_FUNCTIONS_KEY, 10d);
addMeasure(FUNCTIONS_KEY, 0d);
}
@Test
- public void create_measure_from_fall_back_measure() throws Exception {
+ public void create_measure_from_fall_back_measure() {
AverageFormula sut = Builder.newBuilder()
.setOutputMetricKey(FUNCTION_COMPLEXITY_KEY)
.setMainMetricKey(COMPLEXITY_IN_FUNCTIONS_KEY)
}
@Test
- public void not_use_fallback_measure_if_main_measure_exists() throws Exception {
+ public void not_use_fallback_measure_if_main_measure_exists() {
AverageFormula sut = Builder.newBuilder()
.setOutputMetricKey(FUNCTION_COMPLEXITY_KEY)
.setMainMetricKey(COMPLEXITY_IN_FUNCTIONS_KEY)
public class CoreFormulaRepositoryImplTest {
@Test
- public void check_formulas_are_not_empty() throws Exception {
+ public void check_formulas_are_not_empty() {
assertThat(new CoreFormulaRepositoryImpl().getFormulas()).isNotEmpty();
}
ComputeFormulaMeasuresStep sut;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
FormulaRepository formulaRepository = mock(FormulaRepository.class);
when(formulaRepository.getFormulas()).thenReturn(Lists.<Formula>newArrayList(new DistributionFormula(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)));
sut = new ComputeFormulaMeasuresStep(treeRootHolder, measureRepository, metricRepository, formulaRepository);
}
@Test
- public void add_measures() throws Exception {
+ public void add_measures() {
DumbComponent project = builder(PROJECT, 1)
.addChildren(
builder(MODULE, 11)
CounterContext counterContext = mock(CounterContext.class);
@Test
- public void check_new_counter_class() throws Exception {
+ public void check_new_counter_class() {
assertThat(BASIC_DISTRIBUTION_FORMULA.createNewCounter().getClass()).isEqualTo(DistributionFormula.DistributionCounter.class);
}
@Test
- public void fail_with_NPE_when_creating_counter_with_null_metric() throws Exception {
+ public void fail_with_NPE_when_creating_counter_with_null_metric() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Metric key cannot be null");
}
@Test
- public void check_output_metric_key_is_function_complexity_distribution() throws Exception {
+ public void check_output_metric_key_is_function_complexity_distribution() {
assertThat(BASIC_DISTRIBUTION_FORMULA.getOutputMetricKey()).isEqualTo(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY);
}
@Test
- public void create_measure() throws Exception {
+ public void create_measure() {
DistributionFormula.DistributionCounter counter = BASIC_DISTRIBUTION_FORMULA.createNewCounter();
addMeasure(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "0=3;3=7;6=10");
counter.aggregate(counterContext);
}
@Test
- public void create_measure_when_counter_is_aggregating_from_another_counter() throws Exception {
+ public void create_measure_when_counter_is_aggregating_from_another_counter() {
DistributionFormula.DistributionCounter anotherCounter = BASIC_DISTRIBUTION_FORMULA.createNewCounter();
addMeasure(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "0=3;3=7;6=10");
anotherCounter.aggregate(counterContext);
}
@Test
- public void create_no_measure_when_no_value() throws Exception {
+ public void create_no_measure_when_no_value() {
DistributionFormula.DistributionCounter counter = BASIC_DISTRIBUTION_FORMULA.createNewCounter();
when(counterContext.getMeasure(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(Optional.<Measure>absent());
counter.aggregate(counterContext);
}
@Test
- public void not_create_measure_when_on_file() throws Exception {
+ public void not_create_measure_when_on_file() {
DistributionFormula.DistributionCounter counter = BASIC_DISTRIBUTION_FORMULA.createNewCounter();
addMeasure(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "0=3;3=7;6=10");
counter.aggregate(counterContext);
ComputeFormulaMeasuresStep sut;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
FormulaRepository formulaRepository = mock(FormulaRepository.class);
when(formulaRepository.getFormulas()).thenReturn(Lists.<Formula>newArrayList(new SumFormula(LINES_KEY)));
sut = new ComputeFormulaMeasuresStep(treeRootHolder, measureRepository, metricRepository, formulaRepository);
}
@Test
- public void add_measures() throws Exception {
+ public void add_measures() {
DumbComponent project = builder(PROJECT, 1)
.addChildren(
builder(MODULE, 11)
CounterContext counterContext = mock(CounterContext.class);
@Test
- public void check_create_new_counter_class() throws Exception {
+ public void check_create_new_counter_class() {
assertThat(BASIC_SUM_FORMULA.createNewCounter().getClass()).isEqualTo(SumFormula.SumCounter.class);
}
@Test
- public void fail_with_NPE_when_creating_formula_with_null_metric() throws Exception {
+ public void fail_with_NPE_when_creating_formula_with_null_metric() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Metric key cannot be null");
}
@Test
- public void check_output_metric_key_is_lines() throws Exception {
+ public void check_output_metric_key_is_lines() {
assertThat(BASIC_SUM_FORMULA.getOutputMetricKey()).isEqualTo(LINES_KEY);
}
@Test
- public void create_measure() throws Exception {
+ public void create_measure() {
SumFormula.SumCounter counter = BASIC_SUM_FORMULA.createNewCounter();
addMeasure(LINES_KEY, 10);
counter.aggregate(counterContext);
}
@Test
- public void create_measure_when_counter_is_aggregating_from_another_counter() throws Exception {
+ public void create_measure_when_counter_is_aggregating_from_another_counter() {
SumFormula.SumCounter anotherCounter = BASIC_SUM_FORMULA.createNewCounter();
addMeasure(LINES_KEY, 10);
anotherCounter.aggregate(counterContext);
}
@Test
- public void not_create_measure_on_file() throws Exception {
+ public void not_create_measure_on_file() {
SumFormula.SumCounter counter = BASIC_SUM_FORMULA.createNewCounter();
addMeasure(LINES_KEY, 10);
counter.aggregate(counterContext);
}
@Test
- public void not_create_measure_when_value_is_zero() throws Exception {
+ public void not_create_measure_when_value_is_zero() {
SumFormula.SumCounter counter = BASIC_SUM_FORMULA.createNewCounter();
when(counterContext.getMeasure(LINES_KEY)).thenReturn(Optional.<Measure>absent());
counter.aggregate(counterContext);
DebtAggregator underTest = new DebtAggregator(ruleRepository, debtModelHolder, metricRepository, measureRepository);
@Test
- public void sum_debt_of_unresolved_issues() throws Exception {
+ public void sum_debt_of_unresolved_issues() {
DefaultIssue unresolved1 = new DefaultIssue().setDebt(Duration.create(10)).setRuleKey(rule.getKey());
DefaultIssue unresolved2 = new DefaultIssue().setDebt(Duration.create(30)).setRuleKey(rule.getKey());
DefaultIssue unresolvedWithoutDebt = new DefaultIssue().setRuleKey(rule.getKey());
}
@Test
- public void aggregate_debt_of_children() throws Exception {
+ public void aggregate_debt_of_children() {
DefaultIssue fileIssue = new DefaultIssue().setDebt(Duration.create(10)).setRuleKey(rule.getKey());
DefaultIssue projectIssue = new DefaultIssue().setDebt(Duration.create(30)).setRuleKey(rule.getKey());
DebtCalculator underTest = new DebtCalculator(ruleRepository, new Durations(new Settings(), mock(I18n.class)));
@Test
- public void no_debt_if_function_is_not_defined() throws Exception {
+ public void no_debt_if_function_is_not_defined() {
DefaultIssue issue = new DefaultIssue().setRuleKey(rule.getKey());
assertThat(underTest.calculate(issue)).isNull();
}
@Test
- public void default_effort_to_fix_is_one_for_linear_function() throws Exception {
+ public void default_effort_to_fix_is_one_for_linear_function() {
int coefficient = 2;
rule.setFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, coefficient + "min", null));
}
@Test
- public void linear_function() throws Exception {
+ public void linear_function() {
double effortToFix = 3.0;
int coefficient = 2;
issue.setEffortToFix(effortToFix);
}
@Test
- public void constant_function() throws Exception {
+ public void constant_function() {
int constant = 2;
issue.setEffortToFix(null);
rule.setFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, constant + "min"));
}
@Test(expected = IllegalArgumentException.class)
- public void effort_to_fix_must_not_be_set_with_constant_function() throws Exception {
+ public void effort_to_fix_must_not_be_set_with_constant_function() {
int constant = 2;
issue.setEffortToFix(3.0);
rule.setFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, constant + "min"));
}
@Test
- public void linear_with_offset_function() throws Exception {
+ public void linear_with_offset_function() {
double effortToFix = 3.0;
int coefficient = 2;
int offset = 5;
}
@Test
- public void no_default_assignee() throws Exception {
+ public void no_default_assignee() {
assertThat(underTest.getLogin()).isNull();
}
@Test
- public void default_assignee() throws Exception {
+ public void default_assignee() {
settings.setProperty(CoreProperties.DEFAULT_ISSUE_ASSIGNEE, "erik");
when(userIndex.getNullableByLogin("erik")).thenReturn(new UserDoc().setLogin("erik"));
}
@Test
- public void configured_login_does_not_exist() throws Exception {
+ public void configured_login_does_not_exist() {
settings.setProperty(CoreProperties.DEFAULT_ISSUE_ASSIGNEE, "erik");
when(userIndex.getNullableByLogin("erik")).thenReturn(null);
IssueAssigner underTest;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
esTester.truncateIndices();
underTest = new IssueAssigner(new SourceLineIndex(esTester.client()), reportReader, scmAccountToUser, defaultAssignee);
}
IssueCounter sut;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
initMetrics();
measureRepository = new MeasureRepositoryImpl(null, reportReader, metricRepository);
}
@Test
- public void count_issues_by_status() throws Exception {
+ public void count_issues_by_status() {
periodsHolder.setPeriods();
// bottom-up traversal -> from files to project
}
@Test
- public void count_unresolved_issues_by_severity() throws Exception {
+ public void count_unresolved_issues_by_severity() {
periodsHolder.setPeriods();
// bottom-up traversal -> from files to project
}
@Test
- public void count_new_issues() throws Exception {
+ public void count_new_issues() {
Period period = newPeriod(3, 1500000000000L);
periodsHolder.setPeriods(period);
}
@Test
- public void no_measures_if_no_periods() throws Exception {
+ public void no_measures_if_no_periods() {
periodsHolder.setPeriods();
DefaultIssue unresolved = new DefaultIssue().setDebt(Duration.create(10));
verifyZeroInteractions(calculator);
}
@Test
- public void new_debt_if_issue_created_before_period() throws Exception {
+ public void new_debt_if_issue_created_before_period() {
// creation: 1d
// before period: increased to 2d
// after period: increased to 5d, decreased to 4d then increased to 10d
}
@Test
- public void new_debt_is_positive() throws Exception {
+ public void new_debt_is_positive() {
// creation: 1d
// before period: increased to 10d
// after period: decreased to 2d
}
@Test
- public void guess_initial_debt_when_first_change_is_after_period() throws Exception {
+ public void guess_initial_debt_when_first_change_is_after_period() {
// creation: 1d
// after period: increased to 2d, then to 5d
// -> new debt is 5d - 1d = 4d
RuleRepositoryImpl underTest = new RuleRepositoryImpl(cacheLoader);
@Test
- public void getByKey() throws Exception {
+ public void getByKey() {
when(cacheLoader.load(XOO_X1)).thenReturn(new DumbRule(XOO_X1));
assertThat(underTest.getByKey(XOO_X1).getKey()).isEqualTo(XOO_X1);
RuleTagsCopier underTest = new RuleTagsCopier(ruleRepository);
@Test
- public void copy_tags_if_new_rule() throws Exception {
+ public void copy_tags_if_new_rule() {
rule.setTags(Sets.newHashSet("bug", "performance"));
issue.setNew(true);
}
@Test
- public void do_not_copy_tags_if_existing_rule() throws Exception {
+ public void do_not_copy_tags_if_existing_rule() {
rule.setTags(Sets.newHashSet("bug", "performance"));
issue.setNew(false).setTags(asList("misra"));
}
@Test
- public void do_not_copy_tags_if_existing_rule_without_tags() throws Exception {
+ public void do_not_copy_tags_if_existing_rule_without_tags() {
rule.setTags(Sets.newHashSet("bug", "performance"));
issue.setNew(false).setTags(Collections.<String>emptyList());
private static final Language SOME_LANGUAGE = createLanguage(SOME_LANGUAGE_KEY, "_name");
@Test(expected = IllegalArgumentException.class)
- public void constructor_fails_is_language_have_the_same_key() throws Exception {
+ public void constructor_fails_is_language_have_the_same_key() {
new LanguageRepositoryImpl(createLanguage(SOME_LANGUAGE_KEY, " 1"), createLanguage(SOME_LANGUAGE_KEY, " 2"));
}
@Test
- public void find_on_empty_LanguageRepository_returns_absent() throws Exception {
+ public void find_on_empty_LanguageRepository_returns_absent() {
assertThat(new LanguageRepositoryImpl().find(ANY_KEY).isPresent()).isFalse();
}
@Test
- public void find_by_key_returns_the_same_object() throws Exception {
+ public void find_by_key_returns_the_same_object() {
LanguageRepositoryImpl languageRepository = new LanguageRepositoryImpl(SOME_LANGUAGE);
Optional<Language> language = languageRepository.find(SOME_LANGUAGE_KEY);
assertThat(language.isPresent()).isTrue();
}
@Test
- public void find_by_other_key_returns_absent() throws Exception {
+ public void find_by_other_key_returns_absent() {
LanguageRepositoryImpl languageRepository = new LanguageRepositoryImpl(SOME_LANGUAGE);
Optional<Language> language = languageRepository.find(ANY_KEY);
assertThat(language.isPresent()).isFalse();
public ExpectedException thrown = ExpectedException.none();
@Test
- public void fail_with_NPE_when_metric_key_is_null() throws Exception {
+ public void fail_with_NPE_when_metric_key_is_null() {
thrown.expect(NullPointerException.class);
new MeasureKey(null, 1, 2);
}
@Test
- public void fail_with_IAE_when_rule_id_is_default_value() throws Exception {
+ public void fail_with_IAE_when_rule_id_is_default_value() {
thrown.expect(IllegalArgumentException.class);
new MeasureKey("metricKey", -6253, 2);
}
@Test
- public void fail_with_IAE_when_characteristic_id_is_default_value() throws Exception {
+ public void fail_with_IAE_when_characteristic_id_is_default_value() {
thrown.expect(IllegalArgumentException.class);
new MeasureKey("metricKey", 1, -6253);
}
@Test
- public void to_string() throws Exception {
+ public void to_string() {
assertThat(new MeasureKey("metricKey", 1, 2).toString()).isEqualTo("MeasureKey{metricKey='metricKey', ruleId=1, characteristicId=2}");
assertThat(new MeasureKey("metricKey", 1, null).toString()).isEqualTo("MeasureKey{metricKey='metricKey', ruleId=1, characteristicId=-6253}");
assertThat(new MeasureKey("metricKey", null, 2).toString()).isEqualTo("MeasureKey{metricKey='metricKey', ruleId=-6253, characteristicId=2}");
private DbSession dbSession;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(metric1.getKey()).thenReturn(METRIC_KEY_1);
when(metric1.getType()).thenReturn(Metric.MetricType.STRING);
when(metric2.getKey()).thenReturn(METRIC_KEY_2);
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
if (dbSession != null) {
dbSession.close();
}
private MetricRepositoryImpl underTest = new MetricRepositoryImpl(dbClient);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
}
}
@Test
- public void verify_to_string() throws Exception {
+ public void verify_to_string() {
assertThat(new Period(1, CoreProperties.TIMEMACHINE_MODE_VERSION, "2.3", 1420034400000L, 10L).toString())
.isEqualTo("Period{index=1, mode=version, modeParameter=2.3, snapshotDate=1420034400000, snapshotId=10}");
}
private PeriodsHolderImpl underTest = new PeriodsHolderImpl();
@Test
- public void get_periods() throws Exception {
+ public void get_periods() {
List<Period> periods = new ArrayList<>();
periods.add(createPeriod(1));
}
@Test
- public void get_periods_throws_illegal_state_exception_if_not_initialized() throws Exception {
+ public void get_periods_throws_illegal_state_exception_if_not_initialized() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Periods have not been initialized yet");
}
@Test
- public void setPeriods_throws_NPE_if_arg_is_null() throws Exception {
+ public void setPeriods_throws_NPE_if_arg_is_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("Periods cannot be null");
}
@Test
- public void setPeriods_throws_NPE_if_arg_contains_null() throws Exception {
+ public void setPeriods_throws_NPE_if_arg_contains_null() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("No null Period can be added to the holder");
}
@Test
- public void setPeriods_throws_NPE_if_arg_contains_null_among_others() throws Exception {
+ public void setPeriods_throws_NPE_if_arg_contains_null_among_others() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("No null Period can be added to the holder");
}
@Test
- public void setPeriods_throws_ISE_if_already_initialized() throws Exception {
+ public void setPeriods_throws_ISE_if_already_initialized() {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Periods have already been initialized");
}
@Test
- public void update_periods_throws_unsupported_operation_exception() throws Exception {
+ public void update_periods_throws_unsupported_operation_exception() {
thrown.expect(UnsupportedOperationException.class);
underTest.setPeriods(ImmutableList.of(createPeriod(1)));
ApplyPermissionsStep step;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
esTester.truncateIndices();
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
dbSession.close();
}
@Test
- public void grant_permission() throws Exception {
+ public void grant_permission() {
ComponentDto projectDto = ComponentTesting.newProjectDto(PROJECT_UUID).setKey(PROJECT_KEY);
dbClient.componentDao().insert(dbSession, projectDto);
}
@Test
- public void nothing_to_do() throws Exception {
+ public void nothing_to_do() {
long authorizationUpdatedAt = 1000L;
ComponentDto projectDto = ComponentTesting.newProjectDto(PROJECT_UUID).setKey(PROJECT_KEY).setAuthorizationUpdatedAt(authorizationUpdatedAt);
private BuildComponentTreeStep underTest = new BuildComponentTreeStep(reportReader, treeRootHolder);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
reportReader.setMetadata(Metadata.newBuilder().setRootComponentRef(ROOT_REF).build());
}
ComputeFormulaMeasuresStep sut;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
FormulaRepository formulaRepository = mock(FormulaRepository.class);
when(formulaRepository.getFormulas()).thenReturn(Lists.<Formula>newArrayList(new FakeFormula()));
sut = new ComputeFormulaMeasuresStep(treeRootHolder, measureRepository, metricRepository, formulaRepository);
}
@Test
- public void add_measures() throws Exception {
+ public void add_measures() {
DumbComponent project = DumbComponent.builder(PROJECT, 1)
.addChildren(
DumbComponent.builder(MODULE, 11)
}
@Test
- public void add_no_measure() throws Exception {
+ public void add_no_measure() {
DumbComponent project = DumbComponent.builder(PROJECT, 1)
.addChildren(
DumbComponent.builder(MODULE, 11)
}
@Test
- public void add_no_measure_when_no_file() throws Exception {
+ public void add_no_measure_when_no_file() {
DumbComponent project = DumbComponent.builder(PROJECT, 1)
.addChildren(
DumbComponent.builder(MODULE, 11)
}
@Test
- public void add_no_measure_on_module_without_file() throws Exception {
+ public void add_no_measure_on_module_without_file() {
DumbComponent project = DumbComponent.builder(PROJECT, 1)
.addChildren(
DumbComponent.builder(MODULE, 11)
CustomMeasuresCopyStep sut;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
DbClient dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new CustomMeasureDao());
sut = new CustomMeasuresCopyStep(treeRootHolder, dbClient, metricRepository, measureRepository);
}
@Test
- public void copy_custom_measures() throws Exception {
+ public void copy_custom_measures() {
dbTester.prepareDbUnit(getClass(), "custom-measures.xml");
// custom metrics
FeedDebtModelStep sut;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new CharacteristicDao(dbTester.myBatis()));
dbSession = dbClient.openSession(false);
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
dbSession.close();
}
}
@Test
- public void feed_characteristics() throws Exception {
+ public void feed_characteristics() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
sut.execute();
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
dbSession.close();
}
@Test
- public void no_period_on_first_analysis() throws Exception {
+ public void no_period_on_first_analysis() {
// No project, no snapshot
sut.execute();
}
@Test
- public void feed_one_period() throws Exception {
+ public void feed_one_period() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
String textDate = "2008-11-22";
}
@Test
- public void no_period_when_settings_match_no_analysis() throws Exception {
+ public void no_period_when_settings_match_no_analysis() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
settings.setProperty("sonar.timemachine.period1", "UNKNWOWN VERSION");
}
@Test
- public void no_period_when_settings_is_empty() throws Exception {
+ public void no_period_when_settings_is_empty() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
settings.setProperty("sonar.timemachine.period1", "");
}
@Test
- public void ignore_unprocessed_snapshots() throws Exception {
+ public void ignore_unprocessed_snapshots() {
dbTester.prepareDbUnit(getClass(), "unprocessed_snapshots.xml");
settings.setProperty("sonar.timemachine.period1", "100");
}
@Test
- public void feed_period_by_date() throws Exception {
+ public void feed_period_by_date() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
String textDate = "2008-11-22";
}
@Test
- public void search_by_date_return_nearest_later_analysis() throws Exception {
+ public void search_by_date_return_nearest_later_analysis() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
String date = "2008-11-24";
}
@Test
- public void no_period_by_date() throws Exception {
+ public void no_period_by_date() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
// No analysis at and after this date
}
@Test
- public void feed_period_by_days() throws Exception {
+ public void feed_period_by_days() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
settings.setProperty("sonar.timemachine.period1", "10");
}
@Test
- public void no_period_by_days() throws Exception {
+ public void no_period_by_days() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
settings.setProperty("sonar.timemachine.period1", "0");
}
@Test
- public void feed_period_by_previous_analysis() throws Exception {
+ public void feed_period_by_previous_analysis() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
settings.setProperty("sonar.timemachine.period1", "previous_analysis");
}
@Test
- public void no_period_by_previous_analysis() throws Exception {
+ public void no_period_by_previous_analysis() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
settings.setProperty("sonar.timemachine.period1", "previous_analysis");
}
@Test
- public void feed_period_by_previous_version() throws Exception {
+ public void feed_period_by_previous_version() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
settings.setProperty("sonar.timemachine.period1", "previous_version");
}
@Test
- public void feed_period_by_previous_version_wit_previous_version_deleted() throws Exception {
+ public void feed_period_by_previous_version_wit_previous_version_deleted() {
dbTester.prepareDbUnit(getClass(), "previous_version_deleted.xml");
settings.setProperty("sonar.timemachine.period1", "previous_version");
}
@Test
- public void no_period_by_previous_version() throws Exception {
+ public void no_period_by_previous_version() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
settings.setProperty("sonar.timemachine.period1", "previous_version");
}
@Test
- public void no_period_by_previous_version_when_no_event_version() throws Exception {
+ public void no_period_by_previous_version_when_no_event_version() {
dbTester.prepareDbUnit(getClass(), "no_previous_version.xml");
settings.setProperty("sonar.timemachine.period1", "previous_version");
}
@Test
- public void feed_period_by_version() throws Exception {
+ public void feed_period_by_version() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
settings.setProperty("sonar.timemachine.period1", "0.9");
}
@Test
- public void no_period_by_version() throws Exception {
+ public void no_period_by_version() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
settings.setProperty("sonar.timemachine.period1", "0.8");
}
@Test
- public void feed_five_different_periods() throws Exception {
+ public void feed_five_different_periods() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
settings.setProperty("sonar.timemachine.period1", "2008-11-22"); // Analysis from 2008-11-22 should be returned
}
@Test
- public void can_use_qualifier_in_settings() throws Exception {
+ public void can_use_qualifier_in_settings() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
settings.setProperty("sonar.timemachine.period4.TRK", "2008-11-22");
FillComponentsStep sut;
@Before
- public void setup() throws Exception {
+ public void setup() {
dbTester.truncateTables();
session = dbTester.myBatis().openSession(false);
dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new ComponentDao());
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
MyBatis.closeQuietly(session);
}
}
@Test
- public void compute_keys_and_uuids() throws Exception {
+ public void compute_keys_and_uuids() {
reportReader.setMetadata(BatchReport.Metadata.newBuilder()
.setRootComponentRef(1)
.build());
}
@Test
- public void return_existing_uuids() throws Exception {
+ public void return_existing_uuids() {
ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY);
dbClient.componentDao().insert(session, project);
ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY");
}
@Test
- public void use_latest_module_for_files_key() throws Exception {
+ public void use_latest_module_for_files_key() {
reportReader.setMetadata(BatchReport.Metadata.newBuilder()
.setRootComponentRef(1)
.build());
}
@Test
- public void use_branch_to_generate_keys() throws Exception {
+ public void use_branch_to_generate_keys() {
reportReader.setMetadata(BatchReport.Metadata.newBuilder()
.setRootComponentRef(1)
.setBranch("origin/master")
}
@Test
- public void compute_keys_and_uuids_on_project_having_module_and_directory() throws Exception {
+ public void compute_keys_and_uuids_on_project_having_module_and_directory() {
reportReader.setMetadata(BatchReport.Metadata.newBuilder()
.setRootComponentRef(1)
.build());
}
@Test
- public void compute_keys_and_uuids_on_multi_modules() throws Exception {
+ public void compute_keys_and_uuids_on_multi_modules() {
reportReader.setMetadata(BatchReport.Metadata.newBuilder()
.setRootComponentRef(1)
.build());
FillMeasuresWithVariationsStep sut;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
session = dbTester.myBatis().openSession(false);
dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new ComponentDao(), new SnapshotDao(), new MetricDao(), new MeasureDao(), new RuleDao(System2.INSTANCE),
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
session.close();
}
@Test
- public void do_nothing_when_no_raw_measure() throws Exception {
+ public void do_nothing_when_no_raw_measure() {
SnapshotDto period1ProjectSnapshot = createForProject(PROJECT_DTO);
dbClient.snapshotDao().insert(session, period1ProjectSnapshot);
dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), PROJECT_DTO.getId(), period1ProjectSnapshot.getId(), 60d));
}
@Test
- public void do_nothing_when_no_period() throws Exception {
+ public void do_nothing_when_no_period() {
Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_DTO.uuid()).build();
treeRootHolder.setRoot(project);
periodsHolder.setPeriods();
}
@Test
- public void set_variation() throws Exception {
+ public void set_variation() {
// Project
SnapshotDto period1ProjectSnapshot = createForProject(PROJECT_DTO);
dbClient.snapshotDao().insert(session, period1ProjectSnapshot);
}
@Test
- public void set_variations_on_all_periods() throws Exception {
+ public void set_variations_on_all_periods() {
SnapshotDto period1ProjectSnapshot = createForProject(PROJECT_DTO).setLast(false);
SnapshotDto period2ProjectSnapshot = createForProject(PROJECT_DTO).setLast(false);
SnapshotDto period3ProjectSnapshot = createForProject(PROJECT_DTO).setLast(false);
}
@Test
- public void set_variation_on_all_numeric_metrics() throws Exception {
+ public void set_variation_on_all_numeric_metrics() {
SnapshotDto period1ProjectSnapshot = createForProject(PROJECT_DTO);
dbClient.snapshotDao().insert(session, period1ProjectSnapshot);
dbClient.measureDao().insert(session,
}
@Test
- public void read_measure_from_batch() throws Exception {
+ public void read_measure_from_batch() {
// Project
SnapshotDto period1ProjectSnapshot = createForProject(PROJECT_DTO);
dbClient.snapshotDao().insert(session, period1ProjectSnapshot);
IndexComponentsStep sut = new IndexComponentsStep(resourceIndexDao, dbIdsRepository, treeRootHolder);
@Test
- public void call_indexProject_of_dao() throws IOException {
+ public void call_indexProject_of_dao() {
Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("PROJECT_UUID").setKey(PROJECT_KEY).build();
dbIdsRepository.setComponentId(project, 123L);
treeRootHolder.setRoot(project);
public static final DumbComponent FILE_COMPONENT = DumbComponent.builder(Component.Type.FILE, 1).setFileAttributes(new FileAttributes(false, null)).build();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
periodsHolder.setPeriods(
new Period(2, "mode_p_1", null, parseDate("2009-12-25").getTime(), 1),
new Period(5, "mode_p_5", null, parseDate("2011-02-18").getTime(), 2));
}
@Test
- public void persist_components() throws Exception {
+ public void persist_components() {
reportReader.putComponent(BatchReport.Component.newBuilder()
.setRef(1)
.setType(Constants.ComponentType.PROJECT)
}
@Test
- public void persist_file_directly_attached_on_root_directory() throws Exception {
+ public void persist_file_directly_attached_on_root_directory() {
reportReader.putComponent(BatchReport.Component.newBuilder()
.setRef(1)
.setType(Constants.ComponentType.PROJECT)
}
@Test
- public void persist_unit_test() throws Exception {
+ public void persist_unit_test() {
reportReader.putComponent(BatchReport.Component.newBuilder()
.setRef(1)
.setType(Constants.ComponentType.PROJECT)
}
@Test
- public void persist_only_new_components() throws Exception {
+ public void persist_only_new_components() {
// Project amd module already exists
ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(session, project);
}
@Test
- public void compute_parent_project_id() throws Exception {
+ public void compute_parent_project_id() {
reportReader.putComponent(BatchReport.Component.newBuilder()
.setRef(1)
.setType(Constants.ComponentType.PROJECT)
}
@Test
- public void persist_multi_modules() throws Exception {
+ public void persist_multi_modules() {
reportReader.putComponent(BatchReport.Component.newBuilder()
.setRef(1)
.setType(Constants.ComponentType.PROJECT)
}
@Test
- public void nothing_to_persist() throws Exception {
+ public void nothing_to_persist() {
ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(session, project);
ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module");
}
@Test
- public void update_module_name() throws Exception {
+ public void update_module_name() {
ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(session, project);
ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module").setPath("path");
}
@Test
- public void update_module_description() throws Exception {
+ public void update_module_description() {
ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project").setDescription("Project description");
dbClient.componentDao().insert(session, project);
ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module");
}
@Test
- public void update_module_path() throws Exception {
+ public void update_module_path() {
ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(session, project);
ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module").setPath("path");
}
@Test
- public void update_module_uuid_when_moving_a_module() throws Exception {
+ public void update_module_uuid_when_moving_a_module() {
ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(session, project);
ComponentDto moduleA = ComponentTesting.newModuleDto("EDCB", project).setKey("MODULE_A").setName("Module A");
}
@Test
- public void do_not_update_created_at_on_existing_component() throws Exception {
+ public void do_not_update_created_at_on_existing_component() {
Date oldDate = DateUtils.parseDate("2015-01-01");
ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project").setCreatedAt(oldDate);
dbClient.componentDao().insert(session, project);
PersistDuplicationsStep sut;
@Before
- public void setup() throws Exception {
+ public void setup() {
dbTester.truncateTables();
session = dbTester.myBatis().openSession(false);
dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new MeasureDao(), new MetricDao());
}
@Test
- public void persist_duplications_on_same_file_linked_on_a_module() throws Exception {
+ public void persist_duplications_on_same_file_linked_on_a_module() {
Component file = DumbComponent.builder(Component.Type.FILE, 3).setUuid("CDEF").setKey("MODULE_KEY:file").build();
Component module = DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY").addChildren(file).build();
Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(module).build();
}
@Test
- public void nothing_to_do_when_no_events_in_report() throws Exception {
+ public void nothing_to_do_when_no_events_in_report() {
dbTester.prepareDbUnit(getClass(), "nothing_to_do_when_no_events_in_report.xml");
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build());
}
@Test
- public void persist_report_events_with_component_children() throws Exception {
+ public void persist_report_events_with_component_children() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
DumbComponent module = DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").build();
}
@Test
- public void create_version_event() throws Exception {
+ public void create_version_event() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setVersion("1.0").build();
}
@Test
- public void keep_one_event_by_version() throws Exception {
+ public void keep_one_event_by_version() {
dbTester.prepareDbUnit(getClass(), "keep_one_event_by_version.xml");
Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setVersion("1.5-SNAPSHOT").build();
long now = 123456789L;
@Before
- public void setup() throws Exception {
+ public void setup() {
dbTester.truncateTables();
session = dbTester.myBatis().openSession(false);
dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new FileSourceDao(dbTester.myBatis()));
}
@Test
- public void persist_sources() throws Exception {
+ public void persist_sources() {
initBasicReport(2);
sut.execute();
}
@Test
- public void persist_last_line() throws Exception {
+ public void persist_last_line() {
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren(
DumbComponent.builder(Component.Type.FILE, FILE_REF).setUuid(FILE_UUID).setKey("PROJECT_KEY:file").build())
.build());
}
@Test
- public void persist_source_hashes() throws Exception {
+ public void persist_source_hashes() {
initBasicReport(2);
sut.execute();
}
@Test
- public void persist_coverage() throws Exception {
+ public void persist_coverage() {
initBasicReport(1);
reportReader.putCoverage(FILE_REF, newArrayList(BatchReport.Coverage.newBuilder()
}
@Test
- public void persist_scm() throws Exception {
+ public void persist_scm() {
initBasicReport(1);
reportReader.putChangesets(BatchReport.Changesets.newBuilder()
}
@Test
- public void persist_highlighting() throws Exception {
+ public void persist_highlighting() {
initBasicReport(1);
reportReader.putSyntaxHighlighting(FILE_REF, newArrayList(BatchReport.SyntaxHighlighting.newBuilder()
}
@Test
- public void persist_symbols() throws Exception {
+ public void persist_symbols() {
initBasicReport(3);
reportReader.putSymbols(FILE_REF, newArrayList(
}
@Test
- public void persist_duplication() throws Exception {
+ public void persist_duplication() {
initBasicReport(1);
reportReader.putDuplications(FILE_REF, newArrayList(
}
@Test
- public void not_update_sources_when_nothing_has_changed() throws Exception {
+ public void not_update_sources_when_nothing_has_changed() {
// Existing sources
long past = 150000L;
String srcHash = "137f72c3708c6bd0de00a0e5a69c699b";
}
@Test
- public void update_sources_when_source_updated() throws Exception {
+ public void update_sources_when_source_updated() {
// Existing sources
long past = 150000L;
dbClient.fileSourceDao().insert(session, new FileSourceDto()
}
@Test
- public void update_sources_when_src_hash_is_missing() throws Exception {
+ public void update_sources_when_src_hash_is_missing() {
// Existing sources
long past = 150000L;
dbClient.fileSourceDao().insert(session, new FileSourceDto()
}
@Test
- public void display_file_path_when_exception_is_generated() throws Exception {
+ public void display_file_path_when_exception_is_generated() {
initBasicReport(1);
reportReader.putSyntaxHighlighting(FILE_REF, newArrayList(BatchReport.SyntaxHighlighting.newBuilder()
}
}
- private void initBasicReport(int numberOfLines) throws IOException {
+ private void initBasicReport(int numberOfLines) {
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren(
DumbComponent.builder(Component.Type.MODULE, 2).setUuid("MODULE").setKey("MODULE_KEY").addChildren(
DumbComponent.builder(Component.Type.FILE, FILE_REF).setUuid(FILE_UUID).setKey("MODULE_KEY:src/Foo.java").build())
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
session.close();
}
@Test
- public void insert_measures_from_report() throws Exception {
+ public void insert_measures_from_report() {
metricRepository.add(1, STRING_METRIC);
metricRepository.add(2, DOUBLE_METRIC);
}
@Test(expected = IllegalStateException.class)
- public void fail_with_ISE_when_trying_to_insert_forbidden_measures() throws Exception {
+ public void fail_with_ISE_when_trying_to_insert_forbidden_measures() {
metricRepository.add(1, DUPLICATIONS_DATA);
reportReader.putMeasures(FILE_REF, Arrays.asList(
}
@Test
- public void do_not_insert_file_complexity_distribution_metric_on_files() throws Exception {
+ public void do_not_insert_file_complexity_distribution_metric_on_files() {
metricRepository.add(1, FILE_COMPLEXITY_DISTRIBUTION);
reportReader.putMeasures(PROJECT_REF, Arrays.asList(
}
@Test
- public void do_not_insert_function_complexity_distribution_metric_on_files() throws Exception {
+ public void do_not_insert_function_complexity_distribution_metric_on_files() {
metricRepository.add(1, FUNCTION_COMPLEXITY_DISTRIBUTION);
reportReader.putMeasures(PROJECT_REF, Arrays.asList(
LanguageRepository languageRepository;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
db.truncateTables();
dbClient = new DbClient(db.database(), db.myBatis(), new MeasureDao());
sourceLineIndex = mock(SourceLineIndex.class);
}
@Test
- public void add_links_on_project_and_module() throws Exception {
+ public void add_links_on_project_and_module() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").addChildren(
}
@Test
- public void nothing_to_do_when_link_already_exists() throws Exception {
+ public void nothing_to_do_when_link_already_exists() {
dbTester.prepareDbUnit(getClass(), "nothing_to_do_when_link_already_exists.xml");
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build());
}
@Test
- public void do_not_add_links_on_file() throws Exception {
+ public void do_not_add_links_on_file() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").addChildren(
}
@Test
- public void update_link() throws Exception {
+ public void update_link() {
dbTester.prepareDbUnit(getClass(), "update_link.xml");
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build());
}
@Test
- public void delete_link() throws Exception {
+ public void delete_link() {
dbTester.prepareDbUnit(getClass(), "delete_link.xml");
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build());
}
@Test
- public void not_delete_custom_link() throws Exception {
+ public void not_delete_custom_link() {
dbTester.prepareDbUnit(getClass(), "not_delete_custom_link.xml");
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build());
}
@Test
- public void fail_when_trying_to_add_same_link_type_multiple_times() throws Exception {
+ public void fail_when_trying_to_add_same_link_type_multiple_times() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build());
PersistSnapshotsStep sut;
@Before
- public void setup() throws Exception {
+ public void setup() {
dbTester.truncateTables();
session = dbTester.myBatis().openSession(false);
dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new ComponentDao(), new SnapshotDao());
}
@Test
- public void persist_snapshots() throws Exception {
+ public void persist_snapshots() {
ComponentDto projectDto = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(session, projectDto);
ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_KEY").setName("Module");
}
@Test
- public void persist_unit_test() throws Exception {
+ public void persist_unit_test() {
ComponentDto projectDto = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(session, projectDto);
ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_KEY").setName("Module");
}
@Test
- public void persist_snapshots_on_multi_modules() throws Exception {
+ public void persist_snapshots_on_multi_modules() {
ComponentDto projectDto = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY);
dbClient.componentDao().insert(session, projectDto);
ComponentDto moduleADto = ComponentTesting.newModuleDto("BCDE", projectDto).setKey("MODULE_A");
}
@Test
- public void persist_snapshots_with_periods() throws Exception {
+ public void persist_snapshots_with_periods() {
ComponentDto projectDto = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(session, projectDto);
SnapshotDto snapshotDto = SnapshotTesting.createForProject(projectDto).setCreatedAt(DateUtils.parseDateQuietly("2015-01-01").getTime());
}
@Test
- public void only_persist_snapshots_with_periods_on_project_and_module() throws Exception {
+ public void only_persist_snapshots_with_periods_on_project_and_module() {
periodsHolderRule.setPeriods(new Period(1, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, null, analysisDate, 123L));
ComponentDto projectDto = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
}
@Test
- public void set_no_period_on_snapshots_when_no_period() throws Exception {
+ public void set_no_period_on_snapshots_when_no_period() {
ComponentDto projectDto = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project");
dbClient.componentDao().insert(session, projectDto);
SnapshotDto snapshotDto = SnapshotTesting.createForProject(projectDto);
long now = 123456789L;
@Before
- public void setup() throws Exception {
+ public void setup() {
db.truncateTables();
session = db.myBatis().openSession(false);
dbClient = new DbClient(db.database(), db.myBatis(), new FileSourceDao(db.myBatis()));
PurgeDatastoresStep sut = new PurgeDatastoresStep(mock(DbClient.class, Mockito.RETURNS_DEEP_STUBS), projectCleaner, dbIdsRepository, treeRootHolder, projectSettingsRepository);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(projectSettingsRepository.getProjectSettings(PROJECT_KEY)).thenReturn(new Settings());
}
@Test
- public void call_purge_method_of_the_purge_task() throws IOException {
+ public void call_purge_method_of_the_purge_task() {
Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("UUID-1234").setKey(PROJECT_KEY).build();
treeRootHolder.setRoot(project);
dbIdsRepository.setComponentId(project, 123L);
private QualityGateEventsStep underTest = new QualityGateEventsStep(treeRootHolder, metricRepository, measureRepository, eventRepository, notificationManager);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(metricRepository.getByKey(ALERT_STATUS_KEY)).thenReturn(alertStatusMetric);
treeRootHolder.setRoot(PROJECT_COMPONENT);
}
private QualityGateMeasuresStep underTest = new QualityGateMeasuresStep(treeRootHolder, qualityGateHolder, measureRepository, metricRepository, resultTextConverter);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
treeRootHolder.setRoot(PROJECT_COMPONENT);
when(metricRepository.getByKey(CoreMetrics.ALERT_STATUS_KEY)).thenReturn(ALERT_STATUS_METRIC);
private QualityProfileEventsStep underTest = new QualityProfileEventsStep(treeRootHolder, metricRepository, measureRepository, languageRepository, eventRepository);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
when(metricRepository.getByKey(CoreMetrics.QUALITY_PROFILES_KEY)).thenReturn(qualityProfileMetric);
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("uuid").setKey("key").build());
}
}
@Test
- public void do_not_send_notifications_if_no_subscribers() throws IOException {
+ public void do_not_send_notifications_if_no_subscribers() {
when(notifService.hasProjectSubscribersForTypes(PROJECT_UUID, SendIssueNotificationsStep.NOTIF_TYPES)).thenReturn(false);
sut.execute();
private SqaleMeasuresStep underTest = new SqaleMeasuresStep(treeRootHolder, metricRepository, measureRepository, sqaleRatingSettings);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
// assumes SQALE rating configuration is consistent
when(sqaleRatingSettings.getRatingGrid()).thenReturn(RATING_GRID);
when(sqaleRatingSettings.getSizeMetricKey(LANGUAGE_KEY_1)).thenReturn(METRIC_KEY_1);
ValidateProjectStep sut;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), new ComponentDao(), new SnapshotDao());
dbSession = dbClient.openSession(false);
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
dbSession.close();
}
@Test
- public void not_fail_if_provisioning_enforced_and_project_exists() throws Exception {
+ public void not_fail_if_provisioning_enforced_and_project_exists() {
reportReader.setMetadata(BatchReport.Metadata.newBuilder().setAnalysisDate(DEFAULT_ANALYSIS_TIME).build());
reportReader.putComponent(BatchReport.Component.newBuilder()
.setRef(1)
}
@Test
- public void fail_if_provisioning_enforced_and_project_does_not_exists() throws Exception {
+ public void fail_if_provisioning_enforced_and_project_does_not_exists() {
thrown.expect(MessageException.class);
thrown.expectMessage("Unable to scan non-existing project '" + PROJECT_KEY + "'");
}
@Test
- public void fail_if_provisioning_not_enforced_and_project_does_not_exists() throws Exception {
+ public void fail_if_provisioning_not_enforced_and_project_does_not_exists() {
reportReader.setMetadata(BatchReport.Metadata.newBuilder().setAnalysisDate(DEFAULT_ANALYSIS_TIME).build());
reportReader.putComponent(BatchReport.Component.newBuilder()
.setRef(1)
}
@Test
- public void not_fail_on_valid_branch() throws Exception {
+ public void not_fail_on_valid_branch() {
reportReader.setMetadata(BatchReport.Metadata.newBuilder()
.setAnalysisDate(DEFAULT_ANALYSIS_TIME)
.setBranch("origin/master")
}
@Test
- public void fail_on_invalid_branch() throws Exception {
+ public void fail_on_invalid_branch() {
thrown.expect(MessageException.class);
thrown.expectMessage("Validation of project failed:\n" +
" o \"bran#ch\" is not a valid branch name. Allowed characters are alphanumeric, '-', '_', '.' and '/'.");
}
@Test
- public void fail_on_invalid_key() throws Exception {
+ public void fail_on_invalid_key() {
String invalidProjectKey = "Project\\Key";
thrown.expect(MessageException.class);
}
@Test
- public void fail_if_module_key_is_already_used_as_project_key() throws Exception {
+ public void fail_if_module_key_is_already_used_as_project_key() {
thrown.expect(MessageException.class);
thrown.expectMessage("Validation of project failed:\n" +
" o The project \"" + MODULE_KEY + "\" is already defined in SonarQube but not as a module of project \"" + PROJECT_KEY + "\". " +
}
@Test
- public void fail_if_module_key_already_exists_in_another_project() throws Exception {
+ public void fail_if_module_key_already_exists_in_another_project() {
String anotherProjectKey = "ANOTHER_PROJECT_KEY";
thrown.expect(MessageException.class);
thrown.expectMessage("Validation of project failed:\n" +
}
@Test
- public void fail_if_project_key_already_exists_as_module() throws Exception {
+ public void fail_if_project_key_already_exists_as_module() {
String anotherProjectKey = "ANOTHER_PROJECT_KEY";
thrown.expect(MessageException.class);
thrown.expectMessage("Validation of project failed:\n" +
}
@Test
- public void not_fail_if_analysis_date_is_after_last_analysis() throws Exception {
+ public void not_fail_if_analysis_date_is_after_last_analysis() {
reportReader.setMetadata(BatchReport.Metadata.newBuilder()
.setAnalysisDate(DEFAULT_ANALYSIS_TIME) // 2015-06-01
.build());
}
@Test
- public void fail_if_analysis_date_is_before_last_analysis() throws Exception {
+ public void fail_if_analysis_date_is_before_last_analysis() {
thrown.expect(MessageException.class);
thrown.expectMessage("Validation of project failed:");
thrown.expectMessage("Date of analysis cannot be older than the date of the last known analysis on this project. Value: ");
public class MigrationStepModuleTest {
@Test
- public void verify_count_of_added_MigrationStep_types() throws Exception {
+ public void verify_count_of_added_MigrationStep_types() {
ComponentContainer container = new ComponentContainer();
new MigrationStepModule().configure(container);
assertThat(container.size()).isEqualTo(55);
IssueAuthorizationDao dao = new IssueAuthorizationDao();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
}
public DbTester dbTester = DbTester.create(System2.INSTANCE);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
}
}
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbClient = new DbClient(db.database(), db.myBatis(), new CustomMeasureDao(), new ComponentDao(), new MetricDao());
dbSession = dbClient.openSession(false);
db.truncateTables();
MetricDao metricDao;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbClient = new DbClient(db.database(), db.myBatis(), new MetricDao(), new CustomMeasureDao());
dbSession = dbClient.openSession(false);
db.truncateTables();
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
dbSession.close();
}
DbSession dbSession;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbClient = new DbClient(db.database(), db.myBatis(), new MetricDao());
dbSession = dbClient.openSession(false);
ws = new WsTester(new MetricsWs(new DomainsAction(dbClient)));
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
dbSession.close();
}
WsTester ws;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
ws = new WsTester(new MetricsWs(new TypesAction()));
}
ResourceType resourceType;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
ComponentDao componentDao = new ComponentDao();
ResourceDao resourceDao = new ResourceDao(db.myBatis(), System2.INSTANCE);
PurgeDao purgeDao = new PurgeDao(db.myBatis(), resourceDao, System2.INSTANCE);
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
dbSession.close();
}
ResourceType resourceType;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
ComponentDao componentDao = new ComponentDao();
ResourceDao resourceDao = new ResourceDao(db.myBatis(), System2.INSTANCE);
PurgeDao purgeDao = new PurgeDao(db.myBatis(), resourceDao, System2.INSTANCE);
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
dbSession.close();
}
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
dbSession.close();
}
public class EsSearchModuleTest {
@Test
- public void verify_count_of_added_components() throws Exception {
+ public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new EsSearchModule().configure(container);
assertThat(container.size()).isEqualTo(5);
SourceLineResultSetIterator iterator;
- public void after() throws Exception {
+ public void after() {
if (iterator != null) {
iterator.close();
}
}
@Test(expected = IllegalStateException.class)
- public void fail_if_duplicated_plugin_metrics() throws Exception {
+ public void fail_if_duplicated_plugin_metrics() {
Metrics plugin1 = new TestMetrics(new Metric.Builder("m1", "In first plugin", Metric.ValueType.FLOAT).create());
Metrics plugin2 = new TestMetrics(new Metric.Builder("m1", "In second plugin", Metric.ValueType.FLOAT).create());
}
@Test(expected = IllegalStateException.class)
- public void fail_if_plugin_duplicates_core_metric() throws Exception {
+ public void fail_if_plugin_duplicates_core_metric() {
Metrics plugin = new TestMetrics(new Metric.Builder("ncloc", "In plugin", Metric.ValueType.FLOAT).create());
new RegisterMetrics(dbClient(), new Metrics[]{plugin}).start();
TestResultSetIterator sut;
@After
- public void after() throws Exception {
+ public void after() {
if (sut != null) {
sut.close();
}
private MockUserSession session = new MockUserSession(LOGIN);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
threadLocalUserSession.set(session);
}
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
// clean up for next test
threadLocalUserSession.remove();
}
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
// clean up for next test
threadLocalUserSession.remove();
}
public DbTester dbTester = DbTester.create(System2.INSTANCE);
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
}
}
@Test
- public void should_handle_headers() throws Exception {
+ public void should_handle_headers() {
ServletResponse response = new ServletResponse();
String name = "Content-Disposition";
String value = "attachment; filename=sonarqube.zip";
}
@Test
- public void should_clean_resources() throws PersistitException {
+ public void should_clean_resources() {
Cache<String> c = caches.<String>createCache("test1");
for (int i = 0; i < 1_000_000; i++) {
c.put("a" + i, "a" + i);
}
@Test
- public void should_add_measure_with_big_data() throws InterruptedException {
+ public void should_add_measure_with_big_data() {
Project p = new Project("struts");
assertThat(measureCache.entries()).hasSize(0);
}
@Test
- public void do_not_fail_if_base_issue_without_line() throws Exception {
+ public void do_not_fail_if_base_issue_without_line() {
FakeInput baseInput = new FakeInput("H1", "H2");
Issue base = baseInput.createIssueOnLine(1, RULE_SYSTEM_PRINT, "msg1");
}
@Test
- public void do_not_fail_if_raw_issue_without_line() throws Exception {
+ public void do_not_fail_if_raw_issue_without_line() {
FakeInput baseInput = new FakeInput("H1", "H2");
Issue base = baseInput.createIssue(RULE_SYSTEM_PRINT, "msg1");
}
@Test
- public void do_not_fail_if_raw_line_does_not_exist() throws Exception {
+ public void do_not_fail_if_raw_line_does_not_exist() {
FakeInput baseInput = new FakeInput();
FakeInput rawInput = new FakeInput("H1").addIssue(new Issue(200, "H200", RULE_SYSTEM_PRINT, "msg"));
* SONAR-3072
*/
@Test
- public void recognize_blocks_1() throws Exception {
+ public void recognize_blocks_1() {
FakeInput baseInput = FakeInput.createForSourceLines(
"package example1;",
"",
* SONAR-3072
*/
@Test
- public void recognize_blocks_2() throws Exception {
+ public void recognize_blocks_2() {
FakeInput baseInput = FakeInput.createForSourceLines(
"package example2;",
"",
}
@Test
- public void recognize_blocks_3() throws Exception {
+ public void recognize_blocks_3() {
FakeInput baseInput = FakeInput.createForSourceLines(
"package sample;",
"",
PluginClassloaderFactory factory = new PluginClassloaderFactory(temp);
@Test
- public void create_isolated_classloader() throws Exception {
+ public void create_isolated_classloader() {
PluginClassloaderDef def = basePluginDef();
Map<PluginClassloaderDef, ClassLoader> map = factory.create(asList(def));
}
@Test
- public void create_classloader_compatible_with_with_old_api_dependencies() throws Exception {
+ public void create_classloader_compatible_with_with_old_api_dependencies() {
PluginClassloaderDef def = basePluginDef();
def.setCompatibilityMode(true);
ClassLoader classLoader = factory.create(asList(def)).get(def);
}
@Test
- public void classloader_exports_resources_to_other_classloaders() throws Exception {
+ public void classloader_exports_resources_to_other_classloaders() {
PluginClassloaderDef baseDef = basePluginDef();
PluginClassloaderDef dependentDef = dependentPluginDef();
Map<PluginClassloaderDef, ClassLoader> map = factory.create(asList(baseDef, dependentDef));
* it as base plugin anymore
*/
@Test
- public void l10n_plugins_should_not_extend_english_plugin() throws Exception {
+ public void l10n_plugins_should_not_extend_english_plugin() {
PluginInfo pluginInfo = new PluginInfo("l10nfr").setBasePlugin("l10nen");
assertThat(pluginInfo.getBasePlugin()).isNull();
public class RuleKeyFunctionsTest {
@Test
- public void stringToRuleKey() throws Exception {
+ public void stringToRuleKey() {
Collection<String> strings = Arrays.asList("js:S001", "java:S002");
List<RuleKey> keys = from(strings).transform(RuleKeyFunctions.stringToRuleKey()).toList();
}
@Test
- public void on_static_methods() throws Exception {
+ public void on_static_methods() {
assertThat(TestUtils.hasOnlyPrivateConstructors(RuleKeyFunctions.class)).isTrue();
}
}
ResourceIndexDao dao = dbTester.getDbClient().componentIndexDao();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
}
}
@Test
- public void shouldNotIndexPackages() throws SQLException {
+ public void shouldNotIndexPackages() {
setupData("shouldNotIndexPackages");
dao.indexProject(1);
}
@Test
- public void select_previous_version_snapshots() throws Exception {
+ public void select_previous_version_snapshots() {
db.prepareDbUnit(getClass(), "select_previous_version_snapshots.xml");
List<SnapshotDto> snapshots = sut.selectPreviousVersionSnapshots(session, 1L, "1.2-SNAPSHOT");
ActionPlanDao dao = dbTester.getDbClient().actionPlanDao();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
}
public class IssueChangeMapperTest extends AbstractDaoTestCase {
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
}
}
@Test(expected = NullPointerException.class)
- public void get_value_throw_a_NPE_if_value_is_null() throws Exception {
+ public void get_value_throw_a_NPE_if_value_is_null() {
new PastMeasureDto().getValue();
}
}
NotificationQueueDao dao = new NotificationQueueDao(dbTester.myBatis());
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
}
FileSourceDao sut = dbTester.getDbClient().fileSourceDao();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
dbTester.truncateTables();
}