summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-16 21:41:03 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-16 21:41:03 +0200
commit57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27 (patch)
tree316a18fb54f71039b89ea405915a397018ce8cb8
parent97e740133e533f623b6a0bc774dda3804d8df62f (diff)
downloadsonarqube-57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27.tar.gz
sonarqube-57cb022d1b9751a1a73fcf7a2054aa1b24ab4c27.zip
Rename variables "sut" to "underTest" in tests
-rw-r--r--server/sonar-server/src/test/java/org/sonar/core/computation/dbcleaner/ProjectCleanerTest.java16
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java16
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/app/StartupLogsTest.java12
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/app/WebLoggingTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/ComputationServiceTest.java13
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/ComputationThreadLauncherTest.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/ComputationThreadTest.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueCleanerTest.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueTest.java52
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/debt/DebtModelHolderImplTest.java28
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/formula/AverageFormulaExecutionTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/formula/AverageFormulaTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/formula/DistributionFormulaExecutionTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/formula/SumFormulaExecutionTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedPeriodsStepTest.java46
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/FillComponentsStepTest.java20
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/IndexIssuesStepTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistComponentsStepTest.java34
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/SwitchSnapshotStepTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java26
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/ws/SubmitReportActionTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcherTest.java14
-rw-r--r--sonar-application/src/test/java/org/sonar/application/AppLoggingTest.java8
-rw-r--r--sonar-batch-protocol/src/main/protobuf/batch_report.proto20
-rw-r--r--sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java66
-rw-r--r--sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java90
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/NonNullInputFunctionTest.java6
-rw-r--r--sonar-db/src/test/java/org/sonar/db/activity/ActivityDaoTest.java4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java144
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java52
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java54
-rw-r--r--sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java30
-rw-r--r--sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java40
-rw-r--r--sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java28
-rw-r--r--sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java60
-rw-r--r--sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java22
-rw-r--r--sonar-db/src/test/java/org/sonar/db/source/FileSourceDaoTest.java16
-rw-r--r--sonar-db/src/test/java/org/sonar/db/source/FileSourceDtoTest.java7
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggerTest.java76
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java10
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/log/DefaultProfilerTest.java64
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogbackLoggerTest.java82
44 files changed, 641 insertions, 637 deletions
diff --git a/server/sonar-server/src/test/java/org/sonar/core/computation/dbcleaner/ProjectCleanerTest.java b/server/sonar-server/src/test/java/org/sonar/core/computation/dbcleaner/ProjectCleanerTest.java
index df018db96bd..b50c763a0cf 100644
--- a/server/sonar-server/src/test/java/org/sonar/core/computation/dbcleaner/ProjectCleanerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/core/computation/dbcleaner/ProjectCleanerTest.java
@@ -46,7 +46,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
public class ProjectCleanerTest {
- private ProjectCleaner sut;
+ private ProjectCleaner underTest;
private PurgeDao dao = mock(PurgeDao.class);
private PurgeProfiler profiler = mock(PurgeProfiler.class);
private DefaultPeriodCleaner periodCleaner = mock(DefaultPeriodCleaner.class);
@@ -56,21 +56,21 @@ public class ProjectCleanerTest {
@Before
public void before() {
- this.sut = new ProjectCleaner(dao, periodCleaner, profiler, purgeListener, issueIndex);
+ this.underTest = new ProjectCleaner(dao, periodCleaner, profiler, purgeListener, issueIndex);
}
@Test
public void no_profiling_when_property_is_false() {
settings.setProperty(CoreProperties.PROFILING_LOG_PROPERTY, false);
- sut.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
+ underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
verify(profiler, never()).dump(anyLong(), any(Logger.class));
}
@Test
public void no_indexing_when_no_issue_to_delete() {
- sut.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
+ underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
verifyZeroInteractions(issueIndex);
}
@@ -79,7 +79,7 @@ public class ProjectCleanerTest {
public void profiling_when_property_is_true() {
settings.setProperty(CoreProperties.PROFILING_LOG_PROPERTY, true);
- sut.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
+ underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
verify(profiler).dump(anyLong(), any(Logger.class));
}
@@ -88,7 +88,7 @@ public class ProjectCleanerTest {
public void call_period_cleaner_index_client_and_purge_dao() {
settings.setProperty(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES, 5);
- sut.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
+ underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
verify(periodCleaner).clean(any(DbSession.class), any(Long.class), any(Settings.class));
verify(dao).purge(any(DbSession.class), any(PurgeConfiguration.class), any(PurgeListener.class), any(PurgeProfiler.class));
@@ -99,7 +99,7 @@ public class ProjectCleanerTest {
public void if_dao_purge_fails_it_should_not_interrupt_program_execution() {
doThrow(RuntimeException.class).when(dao).purge(any(DbSession.class), any(PurgeConfiguration.class), any(PurgeListener.class), any(PurgeProfiler.class));
- sut.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
+ underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
verify(dao).purge(any(DbSession.class), any(PurgeConfiguration.class), any(PurgeListener.class), any(PurgeProfiler.class));
}
@@ -108,7 +108,7 @@ public class ProjectCleanerTest {
public void if_profiler_cleaning_fails_it_should_not_interrupt_program_execution() {
doThrow(RuntimeException.class).when(periodCleaner).clean(any(DbSession.class), anyLong(), any(Settings.class));
- sut.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
+ underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings);
verify(periodCleaner).clean(any(DbSession.class), anyLong(), any(Settings.class));
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java
index 8ace24aa377..17db0630499 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexTest.java
@@ -39,18 +39,18 @@ public class ActivityIndexTest {
@ClassRule
public static EsTester es = new EsTester().addDefinitions(new ActivityIndexDefinition(new Settings()));
- ActivityIndex sut;
+ ActivityIndex underTest;
@Before
public void before() {
- sut = new ActivityIndex(es.client());
+ underTest = new ActivityIndex(es.client());
}
@Test
public void search_all() throws Exception {
es.putDocuments("activities", "activity", newDoc(1, 1_500_000_000_000L), newDoc(2, 1_600_000_000_000L));
- SearchResult<ActivityDoc> results = sut.search(new ActivityQuery(), new SearchOptions());
+ SearchResult<ActivityDoc> results = underTest.search(new ActivityQuery(), new SearchOptions());
assertThat(results.getTotal()).isEqualTo(2L);
assertThat(results.getDocs()).hasSize(2);
assertThat(results.getDocs()).extracting("message").containsOnly("THE_MSG 1", "THE_MSG 2");
@@ -62,11 +62,11 @@ public class ActivityIndexTest {
ActivityQuery query = new ActivityQuery();
query.setTypes(Arrays.asList("ANALYSIS_REPORT"));
- assertThat(sut.search(query, new SearchOptions()).getTotal()).isEqualTo(2L);
+ assertThat(underTest.search(query, new SearchOptions()).getTotal()).isEqualTo(2L);
query = new ActivityQuery();
query.setTypes(Arrays.asList("OTHER", "TYPES"));
- assertThat(sut.search(query, new SearchOptions()).getTotal()).isEqualTo(0L);
+ assertThat(underTest.search(query, new SearchOptions()).getTotal()).isEqualTo(0L);
}
@Test
@@ -75,7 +75,7 @@ public class ActivityIndexTest {
ActivityQuery query = new ActivityQuery();
query.addDataOrFilter("foo", "bar2");
- SearchResult<ActivityDoc> results = sut.search(query, new SearchOptions());
+ SearchResult<ActivityDoc> results = underTest.search(query, new SearchOptions());
assertThat(results.getDocs()).hasSize(1);
assertThat(results.getDocs().get(0).getKey()).isEqualTo("UUID2");
}
@@ -86,13 +86,13 @@ public class ActivityIndexTest {
ActivityQuery query = new ActivityQuery();
query.setSince(new Date(1_550_000_000_000L));
- SearchResult<ActivityDoc> results = sut.search(query, new SearchOptions());
+ SearchResult<ActivityDoc> results = underTest.search(query, new SearchOptions());
assertThat(results.getDocs()).hasSize(1);
assertThat(results.getDocs().get(0).getKey()).isEqualTo("UUID2");
query = new ActivityQuery();
query.setTo(new Date(1_550_000_000_000L));
- results = sut.search(query, new SearchOptions());
+ results = underTest.search(query, new SearchOptions());
assertThat(results.getDocs()).hasSize(1);
assertThat(results.getDocs().get(0).getKey()).isEqualTo("UUID1");
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/app/StartupLogsTest.java b/server/sonar-server/src/test/java/org/sonar/server/app/StartupLogsTest.java
index fbf96397de0..fb617c4b64b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/app/StartupLogsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/app/StartupLogsTest.java
@@ -37,14 +37,14 @@ public class StartupLogsTest {
Tomcat tomcat = mock(Tomcat.class, Mockito.RETURNS_DEEP_STUBS);
Logger logger = mock(Logger.class);
Props props = new Props(new Properties());
- StartupLogs sut = new StartupLogs(props, logger);
+ StartupLogs underTest = new StartupLogs(props, logger);
@Test
public void logAjp() {
Connector connector = newConnector("AJP/1.3", "http");
when(tomcat.getService().findConnectors()).thenReturn(new Connector[] {connector});
- sut.log(tomcat);
+ underTest.log(tomcat);
verify(logger).info("AJP/1.3 connector enabled on port 1234");
verifyNoMoreInteractions(logger);
@@ -55,7 +55,7 @@ public class StartupLogsTest {
Connector connector = newConnector("HTTP/1.1", "http");
when(tomcat.getService().findConnectors()).thenReturn(new Connector[] {connector});
- sut.log(tomcat);
+ underTest.log(tomcat);
verify(logger).info("HTTP connector enabled on port 1234");
verifyNoMoreInteractions(logger);
@@ -66,7 +66,7 @@ public class StartupLogsTest {
Connector connector = newConnector("HTTP/1.1", "https");
when(tomcat.getService().findConnectors()).thenReturn(new Connector[] {connector});
- sut.log(tomcat);
+ underTest.log(tomcat);
verify(logger).info("HTTPS connector enabled on port 1234 | ciphers=JVM defaults");
verifyNoMoreInteractions(logger);
@@ -82,7 +82,7 @@ public class StartupLogsTest {
when(connector.getProtocolHandler()).thenReturn(protocol);
when(tomcat.getService().findConnectors()).thenReturn(new Connector[] {connector});
props.set(TomcatConnectors.PROP_HTTPS_CIPHERS, "SSL_RSA,TLS_RSA_WITH_RC4");
- sut.log(tomcat);
+ underTest.log(tomcat);
verify(logger).info("HTTPS connector enabled on port 1234 | ciphers=SSL_RSA,TLS_RSA_WITH_RC4");
verifyNoMoreInteractions(logger);
@@ -95,7 +95,7 @@ public class StartupLogsTest {
when(connector.getScheme()).thenReturn("spdy");
when(tomcat.getService().findConnectors()).thenReturn(new Connector[] {connector});
try {
- sut.log(tomcat);
+ underTest.log(tomcat);
fail();
} catch (IllegalArgumentException e) {
// expected
diff --git a/server/sonar-server/src/test/java/org/sonar/server/app/WebLoggingTest.java b/server/sonar-server/src/test/java/org/sonar/server/app/WebLoggingTest.java
index 765283ebdb7..648e9c58aa4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/app/WebLoggingTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/app/WebLoggingTest.java
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class WebLoggingTest {
Props props = new Props(new Properties());
- WebLogging sut = new WebLogging();
+ WebLogging underTest = new WebLogging();
@AfterClass
public static void resetLogback() throws Exception {
@@ -45,7 +45,7 @@ public class WebLoggingTest {
@Test
public void log_to_console() {
- LoggerContext ctx = sut.configure(props);
+ LoggerContext ctx = underTest.configure(props);
Logger root = ctx.getLogger(Logger.ROOT_LOGGER_NAME);
Appender appender = root.getAppender("CONSOLE");
@@ -60,14 +60,14 @@ public class WebLoggingTest {
@Test
public void enable_debug_logs() {
props.set("sonar.log.level", "DEBUG");
- LoggerContext ctx = sut.configure(props);
+ LoggerContext ctx = underTest.configure(props);
assertThat(ctx.getLogger(Logger.ROOT_LOGGER_NAME).getLevel()).isEqualTo(Level.DEBUG);
}
@Test
public void enable_trace_logs() {
props.set("sonar.log.level", "TRACE");
- LoggerContext ctx = sut.configure(props);
+ LoggerContext ctx = underTest.configure(props);
assertThat(ctx.getLogger(Logger.ROOT_LOGGER_NAME).getLevel()).isEqualTo(Level.TRACE);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationServiceTest.java
index 9a9e266b62b..199c9e45e66 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationServiceTest.java
@@ -21,7 +21,6 @@ package org.sonar.server.computation;
import com.google.common.collect.ImmutableList;
import java.io.File;
-import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import org.apache.commons.lang.RandomStringUtils;
@@ -55,11 +54,11 @@ public class ComputationServiceTest {
ActivityManager activityManager = mock(ActivityManager.class);
System2 system = mock(System2.class);
AnalysisReportDto dto = AnalysisReportDto.newForTests(1L).setProjectKey("P1").setUuid("U1").setStatus(Status.PENDING);
- ComputationService sut;
+ ComputationService underTest;
@Before
public void setUp() {
- sut = new ComputationService(new ReportQueue.Item(dto, new File("Do_not_care")), steps, activityManager, system);
+ underTest = new ComputationService(new ReportQueue.Item(dto, new File("Do_not_care")), steps, activityManager, system);
}
@Test
@@ -68,7 +67,7 @@ public class ComputationServiceTest {
when(steps.instances()).thenReturn(Arrays.asList(projectStep1, projectStep2));
- sut.process();
+ underTest.process();
// report is integrated -> status is set to SUCCESS
assertThat(dto.getStatus()).isEqualTo(Status.SUCCESS);
@@ -89,7 +88,7 @@ public class ComputationServiceTest {
when(steps.instances()).thenReturn(Collections.<ComputationStep>emptyList());
logTester.setLevel(LoggerLevel.DEBUG);
- sut.process();
+ underTest.process();
assertThat(logTester.logs(LoggerLevel.DEBUG)).isNotEmpty();
}
@@ -101,7 +100,7 @@ public class ComputationServiceTest {
doThrow(new IllegalStateException(errorMessage)).when(projectStep1).execute();
try {
- sut.process();
+ underTest.process();
fail();
} catch (IllegalStateException e) {
assertThat(e.getMessage()).isEqualTo(errorMessage);
@@ -116,7 +115,7 @@ public class ComputationServiceTest {
doThrow(new IllegalStateException("pb")).when(projectStep1).execute();
try {
- sut.process();
+ underTest.process();
fail();
} catch (IllegalStateException e) {
assertThat(e.getMessage()).isEqualTo("pb");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationThreadLauncherTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationThreadLauncherTest.java
index 2a2dba5605f..7d5d70e0b13 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationThreadLauncherTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationThreadLauncherTest.java
@@ -41,7 +41,7 @@ public class ComputationThreadLauncherTest {
@Rule
public TestRule timeout = new DisableOnDebug(Timeout.seconds(60));
- ComputationThreadLauncher sut;
+ ComputationThreadLauncher underTest;
ReportQueue queue;
ComponentContainer componentContainer;
ContainerFactory containerFactory;
@@ -55,14 +55,14 @@ public class ComputationThreadLauncherTest {
@After
public void after() {
- sut.stop();
+ underTest.stop();
}
@Test
public void call_findAndBook_when_launching_a_recurrent_task() throws Exception {
- sut = new ComputationThreadLauncher(queue, componentContainer, containerFactory, 0, 1, TimeUnit.MILLISECONDS);
+ underTest = new ComputationThreadLauncher(queue, componentContainer, containerFactory, 0, 1, TimeUnit.MILLISECONDS);
- sut.onServerStart(mock(Server.class));
+ underTest.onServerStart(mock(Server.class));
sleep();
@@ -71,10 +71,10 @@ public class ComputationThreadLauncherTest {
@Test
public void call_findAndBook_when_executing_task_immediately() throws Exception {
- sut = new ComputationThreadLauncher(queue, componentContainer, containerFactory, 1, 1, TimeUnit.HOURS);
- sut.start();
+ underTest = new ComputationThreadLauncher(queue, componentContainer, containerFactory, 1, 1, TimeUnit.HOURS);
+ underTest.start();
- sut.startAnalysisTaskNow();
+ underTest.startAnalysisTaskNow();
sleep();
@@ -83,8 +83,8 @@ public class ComputationThreadLauncherTest {
@Test
public void test_real_constructor() throws Exception {
- sut = new ComputationThreadLauncher(queue, componentContainer);
- sut.start();
+ underTest = new ComputationThreadLauncher(queue, componentContainer);
+ underTest.start();
}
private void sleep() throws InterruptedException {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationThreadTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationThreadTest.java
index d684d3ad9b5..370bbe72210 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationThreadTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/ComputationThreadTest.java
@@ -48,13 +48,13 @@ public class ComputationThreadTest {
ReportQueue queue = mock(ReportQueue.class);
ComponentContainer componentContainer = mock(ComponentContainer.class);
ContainerFactory containerFactory = mock(ContainerFactory.class);
- ComputationThread sut = new ComputationThread(queue, componentContainer, containerFactory);
+ ComputationThread underTest = new ComputationThread(queue, componentContainer, containerFactory);
@Test
public void do_nothing_if_queue_empty() {
when(queue.pop()).thenReturn(null);
- sut.run();
+ underTest.run();
verify(queue).pop();
verifyZeroInteractions(containerFactory);
@@ -68,7 +68,7 @@ public class ComputationThreadTest {
when(queue.pop()).thenReturn(item);
when(containerFactory.create(componentContainer, item)).thenReturn(mock(ComputeEngineContainer.class));
- sut.run();
+ underTest.run();
verify(queue).pop();
verify(containerFactory).create(componentContainer, item);
@@ -78,7 +78,7 @@ public class ComputationThreadTest {
public void handle_error_during_queue_pop() {
when(queue.pop()).thenThrow(new IllegalStateException());
- sut.run();
+ underTest.run();
assertThat(logTester.logs()).contains("Failed to pop the queue of analysis reports");
}
@@ -92,7 +92,7 @@ public class ComputationThreadTest {
when(queue.pop()).thenReturn(item);
doThrow(new IllegalStateException("pb")).when(queue).remove(item);
- sut.run();
+ underTest.run();
assertThat(logTester.logs()).contains("Failed to remove analysis report 1 from queue");
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueCleanerTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueCleanerTest.java
index dde45514bd4..38a587590c3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueCleanerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueCleanerTest.java
@@ -29,20 +29,20 @@ public class ReportQueueCleanerTest {
ServerUpgradeStatus serverUpgradeStatus = mock(ServerUpgradeStatus.class);
ReportQueue queue = mock(ReportQueue.class);
- ReportQueueCleaner sut = new ReportQueueCleaner(serverUpgradeStatus, queue);
+ ReportQueueCleaner underTest = new ReportQueueCleaner(serverUpgradeStatus, queue);
@Test
public void reset_reports_on_restart() {
- sut.start();
+ underTest.start();
verify(queue).resetToPendingStatus();
- sut.stop();
+ underTest.stop();
}
@Test
public void delete_all_reports_on_upgrade() {
when(serverUpgradeStatus.isUpgraded()).thenReturn(Boolean.TRUE);
- sut.start();
+ underTest.start();
verify(queue).clear();
- sut.stop();
+ underTest.stop();
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueTest.java
index 9c241ad817b..58e7dba905d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueTest.java
@@ -61,7 +61,7 @@ public class ReportQueueTest {
Settings settings = new Settings();
File dataDir;
- ReportQueue sut;
+ ReportQueue underTest;
@Before
public void setUp() throws Exception {
@@ -69,7 +69,7 @@ public class ReportQueueTest {
settings.setProperty(ProcessProperties.PATH_DATA, dataDir.getAbsolutePath());
when(system.now()).thenReturn(NOW);
- sut = new ReportQueue(dbClient, settings);
+ underTest = new ReportQueue(dbClient, settings);
}
@Test
@@ -77,7 +77,7 @@ public class ReportQueueTest {
// must:
// 1. insert metadata in db
// 2. copy report content to directory /data/analysis
- ReportQueue.Item item = sut.add("P1", "Project 1", generateData());
+ ReportQueue.Item item = underTest.add("P1", "Project 1", generateData());
assertThat(item).isNotNull();
assertThat(item.zipFile).isFile().exists().hasContent("some data").hasParent(new File(dataDir, "analysis"));
@@ -104,47 +104,47 @@ public class ReportQueueTest {
@Test
public void pop_pending_items_in_fifo_order() {
- sut.add("P1", "Project 1", generateData());
- sut.add("P2", "Project 2", generateData());
- sut.add("P3", "Project 3", generateData());
+ underTest.add("P1", "Project 1", generateData());
+ underTest.add("P2", "Project 2", generateData());
+ underTest.add("P3", "Project 3", generateData());
- ReportQueue.Item item = sut.pop();
+ ReportQueue.Item item = underTest.pop();
assertThat(item.dto.getProjectKey()).isEqualTo("P1");
assertThat(item.zipFile).exists().isFile().hasExtension("zip");
// status changed from PENDING to WORKING
assertThat(item.dto.getStatus()).isEqualTo(WORKING);
- assertThat(sut.pop().dto.getProjectKey()).isEqualTo("P2");
- assertThat(sut.pop().dto.getProjectKey()).isEqualTo("P3");
+ assertThat(underTest.pop().dto.getProjectKey()).isEqualTo("P2");
+ assertThat(underTest.pop().dto.getProjectKey()).isEqualTo("P3");
// queue is empty
- assertThat(sut.pop()).isNull();
+ assertThat(underTest.pop()).isNull();
// items are still in db, but in WORKING status
- List<AnalysisReportDto> reports = sut.all();
+ List<AnalysisReportDto> reports = underTest.all();
assertThat(reports).hasSize(3);
assertThat(reports).extracting("status").containsOnly(WORKING);
}
@Test
public void remove() {
- ReportQueue.Item item = sut.add("P1", "Project 1", generateData());
+ ReportQueue.Item item = underTest.add("P1", "Project 1", generateData());
assertThat(db.countRowsOfTable("analysis_reports")).isEqualTo(1);
- sut.remove(item);
+ underTest.remove(item);
assertThat(db.countRowsOfTable("analysis_reports")).isEqualTo(0);
assertThat(item.zipFile).doesNotExist();
}
@Test
public void do_not_pop_corrupted_item() {
- ReportQueue.Item item = sut.add("P1", "Project 1", generateData());
+ ReportQueue.Item item = underTest.add("P1", "Project 1", generateData());
// emulate corruption: file is missing on FS
FileUtils.deleteQuietly(item.zipFile);
- assertThat(sut.pop()).isNull();
+ assertThat(underTest.pop()).isNull();
// table sanitized
assertThat(db.countRowsOfTable("analysis_reports")).isEqualTo(0);
@@ -152,11 +152,11 @@ public class ReportQueueTest {
@Test
public void clear() {
- sut.add("P1", "Project 1", generateData());
- sut.add("P2", "Project 2", generateData());
+ underTest.add("P1", "Project 1", generateData());
+ underTest.add("P2", "Project 2", generateData());
assertThat(analysisDir()).exists().isDirectory();
- sut.clear();
+ underTest.clear();
assertThat(db.countRowsOfTable("analysis_reports")).isEqualTo(0);
assertThat(analysisDir()).doesNotExist();
@@ -164,23 +164,23 @@ public class ReportQueueTest {
@Test
public void clear_do_not_fail_when_directory_do_not_exist() {
- sut.clear();
- sut.clear();
+ underTest.clear();
+ underTest.clear();
}
@Test
public void reset_to_pending_status() {
// 2 pending
- sut.add("P1", "Project 1", generateData());
- sut.add("P2", "Project 2", generateData());
+ underTest.add("P1", "Project 1", generateData());
+ underTest.add("P2", "Project 2", generateData());
// pop 1 -> 1 pending and 1 working
- ReportQueue.Item workingItem = sut.pop();
+ ReportQueue.Item workingItem = underTest.pop();
assertThat(workingItem.dto.getStatus()).isEqualTo(WORKING);
- assertThat(sut.all()).extracting("status").contains(PENDING, WORKING);
+ assertThat(underTest.all()).extracting("status").contains(PENDING, WORKING);
- sut.resetToPendingStatus();
- assertThat(sut.all()).extracting("status").containsOnly(PENDING).hasSize(2);
+ underTest.resetToPendingStatus();
+ assertThat(underTest.all()).extracting("status").containsOnly(PENDING).hasSize(2);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/debt/DebtModelHolderImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/debt/DebtModelHolderImplTest.java
index f7386c021c1..8147505f622 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/debt/DebtModelHolderImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/debt/DebtModelHolderImplTest.java
@@ -40,16 +40,16 @@ public class DebtModelHolderImplTest {
private static final Characteristic MAINTAINABILITY = new Characteristic(4, "MAINTAINABILITY", null);
private static final Characteristic READABILITY = new Characteristic(5, "READABILITY", null);
- DebtModelHolderImpl sut = new DebtModelHolderImpl();
+ DebtModelHolderImpl underTest = new DebtModelHolderImpl();
@Test
public void add_and_get_characteristics() {
- sut.addCharacteristics(PORTABILITY, Arrays.asList(COMPILER_RELATED_PORTABILITY, HARDWARE_RELATED_PORTABILITY));
- sut.addCharacteristics(MAINTAINABILITY, singletonList(READABILITY));
+ underTest.addCharacteristics(PORTABILITY, Arrays.asList(COMPILER_RELATED_PORTABILITY, HARDWARE_RELATED_PORTABILITY));
+ underTest.addCharacteristics(MAINTAINABILITY, singletonList(READABILITY));
- assertThat(sut.getRootCharacteristics()).hasSize(2);
- assertThat(sut.getCharacteristicById(PORTABILITY.getId()).getKey()).isEqualTo("PORTABILITY");
- assertThat(sut.getCharacteristicById(COMPILER_RELATED_PORTABILITY.getId()).getKey()).isEqualTo("COMPILER_RELATED_PORTABILITY");
+ assertThat(underTest.getRootCharacteristics()).hasSize(2);
+ assertThat(underTest.getCharacteristicById(PORTABILITY.getId()).getKey()).isEqualTo("PORTABILITY");
+ assertThat(underTest.getCharacteristicById(COMPILER_RELATED_PORTABILITY.getId()).getKey()).isEqualTo("COMPILER_RELATED_PORTABILITY");
}
@Test
@@ -57,7 +57,7 @@ public class DebtModelHolderImplTest {
thrown.expect(NullPointerException.class);
thrown.expectMessage("rootCharacteristic cannot be null");
- sut.addCharacteristics(null, singletonList(COMPILER_RELATED_PORTABILITY));
+ underTest.addCharacteristics(null, singletonList(COMPILER_RELATED_PORTABILITY));
}
@Test
@@ -65,7 +65,7 @@ public class DebtModelHolderImplTest {
thrown.expect(NullPointerException.class);
thrown.expectMessage("subCharacteristics cannot be null");
- sut.addCharacteristics(PORTABILITY, null);
+ underTest.addCharacteristics(PORTABILITY, null);
}
@Test
@@ -73,15 +73,15 @@ public class DebtModelHolderImplTest {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("subCharacteristics cannot be empty");
- sut.addCharacteristics(PORTABILITY, Collections.<Characteristic>emptyList());
+ underTest.addCharacteristics(PORTABILITY, Collections.<Characteristic>emptyList());
}
@Test
public void get_root_characteristics() {
- sut.addCharacteristics(PORTABILITY, Arrays.asList(COMPILER_RELATED_PORTABILITY, READABILITY));
- sut.addCharacteristics(MAINTAINABILITY, singletonList(READABILITY));
+ underTest.addCharacteristics(PORTABILITY, Arrays.asList(COMPILER_RELATED_PORTABILITY, READABILITY));
+ underTest.addCharacteristics(MAINTAINABILITY, singletonList(READABILITY));
- assertThat(sut.getRootCharacteristics()).hasSize(2);
+ assertThat(underTest.getRootCharacteristics()).hasSize(2);
}
@Test
@@ -89,7 +89,7 @@ public class DebtModelHolderImplTest {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Characteristics have not been initialized yet");
- sut.getCharacteristicById(1);
+ underTest.getCharacteristicById(1);
}
@Test
@@ -97,6 +97,6 @@ public class DebtModelHolderImplTest {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Characteristics have not been initialized yet");
- sut.getRootCharacteristics();
+ underTest.getRootCharacteristics();
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/formula/AverageFormulaExecutionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/formula/AverageFormulaExecutionTest.java
index ae1fc1ebb39..29d1f932417 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/formula/AverageFormulaExecutionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/formula/AverageFormulaExecutionTest.java
@@ -59,11 +59,11 @@ public class AverageFormulaExecutionTest {
@Rule
public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
- FormulaExecutorComponentVisitor sut;
+ FormulaExecutorComponentVisitor underTest;
@Before
public void setUp() throws Exception {
- sut = FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
+ underTest = FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
.buildFor(Lists.<Formula>newArrayList(
AverageFormula.Builder.newBuilder()
.setOutputMetricKey(FUNCTION_COMPLEXITY_KEY)
@@ -104,7 +104,7 @@ public class AverageFormulaExecutionTest {
measureRepository.addRawMeasure(1211, COMPLEXITY_IN_FUNCTIONS_KEY, newMeasureBuilder().create(9));
measureRepository.addRawMeasure(1211, FUNCTIONS_KEY, newMeasureBuilder().create(2));
- sut.visit(project);
+ underTest.visit(project);
assertThat(toEntries(measureRepository.getNewRawMeasures(1))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(3d)));
assertThat(toEntries(measureRepository.getNewRawMeasures(11))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(2d)));
@@ -131,7 +131,7 @@ public class AverageFormulaExecutionTest {
treeRootHolder.setRoot(project);
- sut.visit(project);
+ underTest.visit(project);
assertThat(measureRepository.getNewRawMeasures(1)).isEmpty();
assertThat(measureRepository.getNewRawMeasures(11)).isEmpty();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/formula/AverageFormulaTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/formula/AverageFormulaTest.java
index 0cdf92c0a95..e555f4c3ddd 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/formula/AverageFormulaTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/formula/AverageFormulaTest.java
@@ -228,20 +228,20 @@ public class AverageFormulaTest {
@Test
public void not_use_fallback_measure_if_main_measure_exists() {
- AverageFormula sut = Builder.newBuilder()
+ AverageFormula underTest = Builder.newBuilder()
.setOutputMetricKey(FUNCTION_COMPLEXITY_KEY)
.setMainMetricKey(COMPLEXITY_IN_FUNCTIONS_KEY)
.setByMetricKey(FUNCTIONS_KEY)
.setFallbackMetricKey(CoreMetrics.COMPLEXITY_KEY)
.build();
- AverageFormula.AverageCounter counter = sut.createNewCounter();
+ AverageFormula.AverageCounter counter = underTest.createNewCounter();
addMeasure(COMPLEXITY_IN_FUNCTIONS_KEY, 10d);
addMeasure(COMPLEXITY_KEY, 12d);
addMeasure(FUNCTIONS_KEY, 2d);
counter.aggregate(fileAggregateContext);
- assertThat(sut.createMeasure(counter, createMeasureContext).get().getDoubleValue()).isEqualTo(5d);
+ assertThat(underTest.createMeasure(counter, createMeasureContext).get().getDoubleValue()).isEqualTo(5d);
}
private void addMeasure(String metricKey, double value) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/formula/DistributionFormulaExecutionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/formula/DistributionFormulaExecutionTest.java
index 9c5043c6ae5..e1ae8ae9b4f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/formula/DistributionFormulaExecutionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/formula/DistributionFormulaExecutionTest.java
@@ -51,11 +51,11 @@ public class DistributionFormulaExecutionTest {
@Rule
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
- FormulaExecutorComponentVisitor sut;
+ FormulaExecutorComponentVisitor underTest;
@Before
public void setUp() throws Exception {
- sut = FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
+ underTest = FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
.buildFor(Lists.<Formula>newArrayList(new DistributionFormula(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)));
}
@@ -86,7 +86,7 @@ public class DistributionFormulaExecutionTest {
measureRepository.addRawMeasure(1112, FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=0;3.5=2;6.5=1"));
measureRepository.addRawMeasure(1211, FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=1;3.5=3;6.5=2"));
- sut.visit(project);
+ underTest.visit(project);
assertThat(toEntries(measureRepository.getNewRawMeasures(1))).containsOnly(entryOf(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=4;3.5=10;6.5=12")));
assertThat(toEntries(measureRepository.getNewRawMeasures(11))).containsOnly(entryOf(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=3;3.5=7;6.5=10")));
@@ -113,7 +113,7 @@ public class DistributionFormulaExecutionTest {
treeRootHolder.setRoot(project);
- sut.visit(project);
+ underTest.visit(project);
assertThat(measureRepository.getNewRawMeasures(1)).isEmpty();
assertThat(measureRepository.getNewRawMeasures(11)).isEmpty();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/formula/SumFormulaExecutionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/formula/SumFormulaExecutionTest.java
index f7196b29350..1ad69e4f28b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/formula/SumFormulaExecutionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/formula/SumFormulaExecutionTest.java
@@ -51,11 +51,11 @@ public class SumFormulaExecutionTest {
@Rule
public MeasureRepositoryRule measureRepository = MeasureRepositoryRule.create(treeRootHolder, metricRepository);
- FormulaExecutorComponentVisitor sut;
+ FormulaExecutorComponentVisitor underTest;
@Before
public void setUp() throws Exception {
- sut = FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
+ underTest = FormulaExecutorComponentVisitor.newBuilder(metricRepository, measureRepository)
.buildFor(Lists.<Formula>newArrayList(new SumFormula(LINES_KEY)));
}
@@ -86,7 +86,7 @@ public class SumFormulaExecutionTest {
measureRepository.addRawMeasure(1112, LINES_KEY, newMeasureBuilder().create(8));
measureRepository.addRawMeasure(1211, LINES_KEY, newMeasureBuilder().create(2));
- sut.visit(project);
+ underTest.visit(project);
assertThat(toEntries(measureRepository.getNewRawMeasures(1))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(20)));
assertThat(toEntries(measureRepository.getNewRawMeasures(11))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(18)));
@@ -113,7 +113,7 @@ public class SumFormulaExecutionTest {
treeRootHolder.setRoot(project);
- sut.visit(project);
+ underTest.visit(project);
assertThat(measureRepository.getNewRawMeasures(1)).isEmpty();
assertThat(measureRepository.getNewRawMeasures(11)).isEmpty();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedPeriodsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedPeriodsStepTest.java
index 37690be051c..d255c5e26f5 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedPeriodsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedPeriodsStepTest.java
@@ -70,11 +70,11 @@ public class FeedPeriodsStepTest extends BaseStepTest {
Settings settings = new Settings();
- FeedPeriodsStep sut;
+ FeedPeriodsStep underTest;
@Override
protected ComputationStep step() {
- return sut;
+ return underTest;
}
@Before
@@ -85,14 +85,14 @@ public class FeedPeriodsStepTest extends BaseStepTest {
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).setVersion("1.1").build());
- sut = new FeedPeriodsStep(dbClient, settings, treeRootHolder, reportReader, periodsHolder);
+ underTest = new FeedPeriodsStep(dbClient, settings, treeRootHolder, reportReader, periodsHolder);
}
@Test
public void no_period_on_first_analysis() {
// No project, no snapshot
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).isEmpty();
}
@@ -103,7 +103,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
String textDate = "2008-11-22";
settings.setProperty("sonar.timemachine.period1", textDate);
- sut.execute();
+ underTest.execute();
List<Period> periods = periodsHolder.getPeriods();
assertThat(periods).hasSize(1);
@@ -120,7 +120,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "UNKNWOWN VERSION");
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).isEmpty();
}
@@ -130,7 +130,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "");
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).isEmpty();
}
@@ -140,7 +140,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "100");
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).isEmpty();
}
@@ -151,7 +151,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
String textDate = "2008-11-22";
settings.setProperty("sonar.timemachine.period1", textDate);
- sut.execute();
+ underTest.execute();
List<Period> periods = periodsHolder.getPeriods();
assertThat(periods).hasSize(1);
@@ -173,7 +173,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", date);
- sut.execute();
+ underTest.execute();
List<Period> periods = periodsHolder.getPeriods();
assertThat(periods).hasSize(1);
@@ -192,7 +192,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
// No analysis at and after this date
settings.setProperty("sonar.timemachine.period1", "2008-11-30");
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).isEmpty();
}
@@ -202,7 +202,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "10");
- sut.execute();
+ underTest.execute();
List<Period> periods = periodsHolder.getPeriods();
assertThat(periods).hasSize(1);
@@ -223,7 +223,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "0");
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).isEmpty();
}
@@ -233,7 +233,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "previous_analysis");
- sut.execute();
+ underTest.execute();
List<Period> periods = periodsHolder.getPeriods();
assertThat(periods).hasSize(1);
@@ -254,7 +254,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "previous_analysis");
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).isEmpty();
}
@@ -264,7 +264,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "previous_version");
- sut.execute();
+ underTest.execute();
List<Period> periods = periodsHolder.getPeriods();
assertThat(periods).hasSize(1);
@@ -285,7 +285,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "previous_version");
- sut.execute();
+ underTest.execute();
List<Period> periods = periodsHolder.getPeriods();
assertThat(periods).hasSize(1);
@@ -303,7 +303,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "previous_version");
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).isEmpty();
}
@@ -313,7 +313,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "previous_version");
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).isEmpty();
}
@@ -323,7 +323,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "0.9");
- sut.execute();
+ underTest.execute();
List<Period> periods = periodsHolder.getPeriods();
assertThat(periods).hasSize(1);
@@ -344,7 +344,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period1", "0.8");
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).isEmpty();
}
@@ -358,7 +358,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period4", "previous_version"); // Analysis from 2008-11-12 should be returned
settings.setProperty("sonar.timemachine.period5", "0.9"); // Anaylsis from 2008-11-11
- sut.execute();
+ underTest.execute();
List<Period> periods = periodsHolder.getPeriods();
List<String> periodModes = newArrayList(Iterables.transform(periods, new Function<Period, String>() {
@@ -398,7 +398,7 @@ public class FeedPeriodsStepTest extends BaseStepTest {
settings.setProperty("sonar.timemachine.period4.TRK", "2008-11-22");
settings.setProperty("sonar.timemachine.period5.TRK", "previous_analysis");
- sut.execute();
+ underTest.execute();
assertThat(periodsHolder.getPeriods()).hasSize(2);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/FillComponentsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/FillComponentsStepTest.java
index de3761dfdaf..3d33ad862db 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/FillComponentsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/FillComponentsStepTest.java
@@ -57,17 +57,17 @@ public class FillComponentsStepTest extends BaseStepTest {
DbClient dbClient = dbTester.getDbClient();
- FillComponentsStep sut;
+ FillComponentsStep underTest;
@Before
public void setup() {
dbTester.truncateTables();
- sut = new FillComponentsStep(dbClient, reportReader, treeRootHolder);
+ underTest = new FillComponentsStep(dbClient, reportReader, treeRootHolder);
}
@Override
protected ComputationStep step() {
- return sut;
+ return underTest;
}
@Test
@@ -101,7 +101,7 @@ public class FillComponentsStepTest extends BaseStepTest {
.build());
treeRootHolder.setRoot(ComponentTreeBuilder.from(reportReader));
- sut.execute();
+ underTest.execute();
Map<Integer, Component> componentsByRef = getComponentsByRef(treeRootHolder.getRoot());
@@ -158,7 +158,7 @@ public class FillComponentsStepTest extends BaseStepTest {
.build());
treeRootHolder.setRoot(ComponentTreeBuilder.from(reportReader));
- sut.execute();
+ underTest.execute();
Map<Integer, Component> componentsByRef = getComponentsByRef(treeRootHolder.getRoot());
@@ -215,7 +215,7 @@ public class FillComponentsStepTest extends BaseStepTest {
.build());
treeRootHolder.setRoot(ComponentTreeBuilder.from(reportReader));
- sut.execute();
+ underTest.execute();
Map<Integer, Component> componentsByRef = getComponentsByRef(treeRootHolder.getRoot());
@@ -258,7 +258,7 @@ public class FillComponentsStepTest extends BaseStepTest {
.build());
treeRootHolder.setRoot(ComponentTreeBuilder.from(reportReader));
- sut.execute();
+ underTest.execute();
Map<Integer, Component> componentsByRef = getComponentsByRef(treeRootHolder.getRoot());
@@ -311,7 +311,7 @@ public class FillComponentsStepTest extends BaseStepTest {
.build());
treeRootHolder.setRoot(ComponentTreeBuilder.from(reportReader));
- sut.execute();
+ underTest.execute();
Map<Integer, Component> componentsByRef = getComponentsByRef(treeRootHolder.getRoot());
@@ -371,7 +371,7 @@ public class FillComponentsStepTest extends BaseStepTest {
.build());
treeRootHolder.setRoot(ComponentTreeBuilder.from(reportReader));
- sut.execute();
+ underTest.execute();
Map<Integer, Component> componentsByRef = getComponentsByRef(treeRootHolder.getRoot());
@@ -431,7 +431,7 @@ public class FillComponentsStepTest extends BaseStepTest {
.build());
treeRootHolder.setRoot(ComponentTreeBuilder.from(reportReader));
- sut.execute();
+ underTest.execute();
Map<Integer, Component> componentsByRef = getComponentsByRef(treeRootHolder.getRoot());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/IndexIssuesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/IndexIssuesStepTest.java
index 61b0c62e5bd..06e7456b9bf 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/IndexIssuesStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/IndexIssuesStepTest.java
@@ -28,14 +28,12 @@ import static org.mockito.Mockito.verify;
public class IndexIssuesStepTest {
- IndexIssuesStep sut;
-
@Test
public void call_indexers() {
IssueIndexer issueIndexer = mock(IssueIndexer.class);
- sut = new IndexIssuesStep(issueIndexer);
+ IndexIssuesStep underTest = new IndexIssuesStep(issueIndexer);
- sut.execute();
+ underTest.execute();
verify(issueIndexer).index();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistComponentsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistComponentsStepTest.java
index cc2f6992bfe..70ddba505ef 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistComponentsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistComponentsStepTest.java
@@ -72,7 +72,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
Date now;
- PersistComponentsStep sut;
+ PersistComponentsStep underTest;
@Before
public void setup() throws Exception {
@@ -82,12 +82,12 @@ public class PersistComponentsStepTest extends BaseStepTest {
now = DATE_FORMAT.parse("2015-06-02");
when(system2.now()).thenReturn(now.getTime());
- sut = new PersistComponentsStep(dbClient, treeRootHolder, reportReader, dbIdsRepository, system2);
+ underTest = new PersistComponentsStep(dbClient, treeRootHolder, reportReader, dbIdsRepository, system2);
}
@Override
protected ComputationStep step() {
- return sut;
+ return underTest;
}
@Test
@@ -128,7 +128,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(module).build();
treeRootHolder.setRoot(project);
- sut.execute();
+ underTest.execute();
dbTester.getSession().commit();
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(4);
@@ -219,7 +219,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
).build()
).build());
- sut.execute();
+ underTest.execute();
ComponentDto directory = dbClient.componentDao().selectByKey(dbTester.getSession(), "PROJECT_KEY:/").get();
assertThat(directory.name()).isEqualTo("/");
@@ -258,7 +258,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
.build())
.build());
- sut.execute();
+ underTest.execute();
ComponentDto file = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY + ":src/test/java/dir/FooTest.java").get();
assertThat(file.name()).isEqualTo("FooTest.java");
@@ -310,7 +310,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
.build())
.build());
- sut.execute();
+ underTest.execute();
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(4);
@@ -385,7 +385,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
.build())
.build());
- sut.execute();
+ underTest.execute();
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(5);
@@ -446,7 +446,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
DumbComponent.builder(Component.Type.MODULE, 4).setUuid("CDEF").setKey("MODULE_B").build())
.build());
- sut.execute();
+ underTest.execute();
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(4);
@@ -516,7 +516,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
.build())
.build());
- sut.execute();
+ underTest.execute();
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(4);
assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get().getId()).isEqualTo(project.getId());
@@ -586,7 +586,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY").build())
.build());
- sut.execute();
+ underTest.execute();
ComponentDto projectReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get();
assertThat(projectReloaded.name()).isEqualTo("New project name");
@@ -623,7 +623,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY").build())
.build());
- sut.execute();
+ underTest.execute();
ComponentDto projectReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get();
assertThat(projectReloaded.description()).isEqualTo("New project description");
@@ -659,7 +659,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY").build())
.build());
- sut.execute();
+ underTest.execute();
ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get();
assertThat(moduleReloaded.path()).isEqualTo("New path");
@@ -721,7 +721,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
.build())
.build());
- sut.execute();
+ underTest.execute();
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(5);
@@ -771,7 +771,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build());
- sut.execute();
+ underTest.execute();
Optional<ComponentDto> projectReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY);
assertThat(projectReloaded.get().name()).isEqualTo("New project name");
@@ -823,7 +823,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
.build())
.build());
- sut.execute();
+ underTest.execute();
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(4);
assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get().getId()).isEqualTo(project.getId());
@@ -919,7 +919,7 @@ public class PersistComponentsStepTest extends BaseStepTest {
.build())
.build());
- sut.execute();
+ underTest.execute();
// Projects contains 4 components from the report + one removed module
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(5);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java
index b30d26be4d3..d037216c6b6 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java
@@ -81,13 +81,13 @@ public class PersistMeasuresStepTest extends BaseStepTest {
ComponentDto projectDto;
ComponentDto fileDto;
- PersistMeasuresStep sut;
+ PersistMeasuresStep underTest;
@Before
public void setUp() {
dbTester.truncateTables();
- sut = new PersistMeasuresStep(dbClient, metricRepository, dbIdsRepository, treeRootHolder, measureRepository);
+ underTest = new PersistMeasuresStep(dbClient, metricRepository, dbIdsRepository, treeRootHolder, measureRepository);
projectDto = addComponent("project-key");
fileDto = addComponent("file-key");
@@ -110,7 +110,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
measureRepository.addRawMeasure(PROJECT_REF, STRING_METRIC_KEY, Measure.newMeasureBuilder().create("measure-data"));
measureRepository.addRawMeasure(FILE_REF, DOUBLE_METRIC_KEY, Measure.newMeasureBuilder().create(123.123d));
- sut.execute();
+ underTest.execute();
assertThat(dbTester.countRowsOfTable("project_measures")).isEqualTo(2);
@@ -149,7 +149,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
.create(10d)
);
- sut.execute();
+ underTest.execute();
assertThat(dbTester.countRowsOfTable("project_measures")).isEqualTo(1);
List<Map<String, Object>> dtos = selectSnapshots();
@@ -163,7 +163,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
measureRepository.addRawMeasure(FILE_REF, OPTIMIZED_METRIC_KEY, Measure.newMeasureBuilder().create(true));
- sut.execute();
+ underTest.execute();
assertThat(selectSnapshots()).isEmpty();
}
@@ -176,7 +176,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
measureRepository.addRawMeasure(FILE_REF, STRING_METRIC_KEY, Measure.newMeasureBuilder().createNoValue());
measureRepository.addRawMeasure(FILE_REF, DOUBLE_METRIC_KEY, Measure.newMeasureBuilder().createNoValue());
- sut.execute();
+ underTest.execute();
assertThat(selectSnapshots()).isEmpty();
}
@@ -188,7 +188,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
measureRepository.addRawMeasure(PROJECT_REF, FILE_COMPLEXITY_DISTRIBUTION_KEY, Measure.newMeasureBuilder().create("0=1;2=10"));
measureRepository.addRawMeasure(FILE_REF, FILE_COMPLEXITY_DISTRIBUTION_KEY, Measure.newMeasureBuilder().create("0=1;2=10"));
- sut.execute();
+ underTest.execute();
assertThat(dbTester.countRowsOfTable("project_measures")).isEqualTo(1);
@@ -207,7 +207,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
measureRepository.addRawMeasure(PROJECT_REF, FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, Measure.newMeasureBuilder().create("0=1;2=10"));
measureRepository.addRawMeasure(FILE_REF, FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, Measure.newMeasureBuilder().create("0=1;2=10"));
- sut.execute();
+ underTest.execute();
assertThat(dbTester.countRowsOfTable("project_measures")).isEqualTo(1);
@@ -243,6 +243,6 @@ public class PersistMeasuresStepTest extends BaseStepTest {
@Override
protected ComputationStep step() {
- return sut;
+ return underTest;
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/SwitchSnapshotStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/SwitchSnapshotStepTest.java
index 9c29f36b893..90cecee3056 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/SwitchSnapshotStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/SwitchSnapshotStepTest.java
@@ -49,14 +49,14 @@ public class SwitchSnapshotStepTest {
DbIdsRepository dbIdsRepository = new DbIdsRepository();
- SwitchSnapshotStep sut;
+ SwitchSnapshotStep underTest;
@Before
public void before() {
db.truncateTables();
System2 system2 = mock(System2.class);
when(system2.now()).thenReturn(DateUtils.parseDate("2011-09-29").getTime());
- this.sut = new SwitchSnapshotStep(new DbClient(db.database(), db.myBatis(), new SnapshotDao()), treeRootHolder, dbIdsRepository);
+ underTest = new SwitchSnapshotStep(new DbClient(db.database(), db.myBatis(), new SnapshotDao()), treeRootHolder, dbIdsRepository);
}
@Test
@@ -67,7 +67,7 @@ public class SwitchSnapshotStepTest {
treeRootHolder.setRoot(project);
dbIdsRepository.setSnapshotId(project, 1);
- sut.execute();
+ underTest.execute();
db.assertDbUnit(getClass(), "snapshots-result.xml", "snapshots");
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java
index 6a7b09d947b..b4432ee159e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java
@@ -65,14 +65,14 @@ public class ValidateProjectStepTest {
Settings settings;
- ValidateProjectStep sut;
+ ValidateProjectStep underTest;
@Before
public void setUp() {
dbTester.truncateTables();
settings = new Settings();
- sut = new ValidateProjectStep(dbClient, settings, reportReader, treeRootHolder);
+ underTest = new ValidateProjectStep(dbClient, settings, reportReader, treeRootHolder);
}
@Test
@@ -89,7 +89,7 @@ public class ValidateProjectStepTest {
dbTester.getSession().commit();
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build());
- sut.execute();
+ underTest.execute();
}
@Test
@@ -107,7 +107,7 @@ public class ValidateProjectStepTest {
settings.appendProperty(CoreProperties.CORE_PREVENT_AUTOMATIC_PROJECT_CREATION, "true");
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build());
- sut.execute();
+ underTest.execute();
}
@Test
@@ -122,7 +122,7 @@ public class ValidateProjectStepTest {
settings.appendProperty(CoreProperties.CORE_PREVENT_AUTOMATIC_PROJECT_CREATION, "false");
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build());
- sut.execute();
+ underTest.execute();
}
@Test
@@ -138,7 +138,7 @@ public class ValidateProjectStepTest {
.build());
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY + ":origin/master").build());
- sut.execute();
+ underTest.execute();
}
@Test
@@ -158,7 +158,7 @@ public class ValidateProjectStepTest {
.build());
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY + ":bran#ch").build());
- sut.execute();
+ underTest.execute();
}
@Test
@@ -186,7 +186,7 @@ public class ValidateProjectStepTest {
DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("Module$Key").build())
.build());
- sut.execute();
+ underTest.execute();
}
@Test
@@ -218,7 +218,7 @@ public class ValidateProjectStepTest {
DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY).build())
.build());
- sut.execute();
+ underTest.execute();
}
@Test
@@ -252,7 +252,7 @@ public class ValidateProjectStepTest {
DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY).build())
.build());
- sut.execute();
+ underTest.execute();
}
@Test
@@ -287,7 +287,7 @@ public class ValidateProjectStepTest {
DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY).build())
.build());
- sut.execute();
+ underTest.execute();
}
@Test
@@ -309,7 +309,7 @@ public class ValidateProjectStepTest {
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build());
- sut.execute();
+ underTest.execute();
}
@Test
@@ -336,6 +336,6 @@ public class ValidateProjectStepTest {
treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build());
- sut.execute();
+ underTest.execute();
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/SubmitReportActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/SubmitReportActionTest.java
index 6a2016b5be2..b269c55398f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/SubmitReportActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/SubmitReportActionTest.java
@@ -49,19 +49,19 @@ public class SubmitReportActionTest {
ComputationThreadLauncher workerLauncher = mock(ComputationThreadLauncher.class);
ReportQueue queue = mock(ReportQueue.class);
WsTester wsTester;
- SubmitReportAction sut;
+ SubmitReportAction underTest;
@Before
public void before() {
- sut = new SubmitReportAction(queue, workerLauncher, userSessionRule);
- wsTester = new WsTester(new ComputationWs(sut));
+ underTest = new SubmitReportAction(queue, workerLauncher, userSessionRule);
+ wsTester = new WsTester(new ComputationWs(underTest));
}
@Test
public void define_metadata() {
WebService.Context context = new WebService.Context();
WebService.NewController controller = context.createController("api/computation");
- sut.define(controller);
+ underTest.define(controller);
controller.done();
WebService.Action action = context.controller("api/computation").action("submit_report");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest.java
index d285bcd677c..5494152bdf7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest.java
@@ -30,24 +30,24 @@ public class FeedIssueComponentUuidsTest {
@Rule
public DbTester db = DbTester.createForSchema(System2.INSTANCE, FeedIssueComponentUuidsTest.class, "schema.sql");
- FeedIssueComponentUuids sut;
+ FeedIssueComponentUuids underTest;
@Before
public void setUp() {
db.truncateTables();
- sut = new FeedIssueComponentUuids(db.database());
+ underTest = new FeedIssueComponentUuids(db.database());
}
@Test
public void migrate_empty_db() throws Exception {
- sut.execute();
+ underTest.execute();
}
@Test
public void migrate() throws Exception {
db.prepareDbUnit(this.getClass(), "before.xml");
- sut.execute();
+ underTest.execute();
db.assertDbUnit(this.getClass(), "after-result.xml", "issues");
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcherTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcherTest.java
index 91061b4cb7e..4d319ba95c7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcherTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcherTest.java
@@ -37,12 +37,12 @@ public class DoNotFixNotificationDispatcherTest {
NotificationDispatcher.Context context = mock(NotificationDispatcher.Context.class);
NotificationChannel emailChannel = mock(NotificationChannel.class);
NotificationChannel twitterChannel = mock(NotificationChannel.class);
- DoNotFixNotificationDispatcher sut = new DoNotFixNotificationDispatcher(notifications);;
+ DoNotFixNotificationDispatcher underTest = new DoNotFixNotificationDispatcher(notifications);;
@Test
public void test_metadata() throws Exception {
NotificationDispatcherMetadata metadata = DoNotFixNotificationDispatcher.newMetadata();
- assertThat(metadata.getDispatcherKey()).isEqualTo(sut.getKey());
+ assertThat(metadata.getDispatcherKey()).isEqualTo(underTest.getKey());
assertThat(metadata.getProperty(NotificationDispatcherMetadata.GLOBAL_NOTIFICATION)).isEqualTo("true");
assertThat(metadata.getProperty(NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION)).isEqualTo("true");
}
@@ -50,7 +50,7 @@ public class DoNotFixNotificationDispatcherTest {
@Test
public void should_not_dispatch_if_other_notification_type() {
Notification notification = new Notification("other");
- sut.performDispatch(notification, context);
+ underTest.performDispatch(notification, context);
verify(context, never()).addUser(any(String.class), any(NotificationChannel.class));
}
@@ -61,13 +61,13 @@ public class DoNotFixNotificationDispatcherTest {
recipients.put("simon", emailChannel);
recipients.put("freddy", twitterChannel);
recipients.put("godin", twitterChannel);
- when(notifications.findNotificationSubscribers(sut, "struts")).thenReturn(recipients);
+ when(notifications.findNotificationSubscribers(underTest, "struts")).thenReturn(recipients);
Notification fpNotif = new IssueChangeNotification().setFieldValue("projectKey", "struts")
.setFieldValue("changeAuthor", "godin")
.setFieldValue("new.resolution", Issue.RESOLUTION_FALSE_POSITIVE)
.setFieldValue("assignee", "freddy");
- sut.performDispatch(fpNotif, context);
+ underTest.performDispatch(fpNotif, context);
verify(context).addUser("simon", emailChannel);
verify(context).addUser("freddy", twitterChannel);
@@ -84,13 +84,13 @@ public class DoNotFixNotificationDispatcherTest {
Multimap<String, NotificationChannel> recipients = HashMultimap.create();
recipients.put("simon", emailChannel);
recipients.put("freddy", twitterChannel);
- when(notifications.findNotificationSubscribers(sut, "struts")).thenReturn(recipients);
+ when(notifications.findNotificationSubscribers(underTest, "struts")).thenReturn(recipients);
Notification fixedNotif = new IssueChangeNotification().setFieldValue("projectKey", "struts")
.setFieldValue("changeAuthor", "godin")
.setFieldValue("new.resolution", Issue.RESOLUTION_FIXED)
.setFieldValue("assignee", "freddy");
- sut.performDispatch(fixedNotif, context);
+ underTest.performDispatch(fixedNotif, context);
verifyZeroInteractions(context);
}
diff --git a/sonar-application/src/test/java/org/sonar/application/AppLoggingTest.java b/sonar-application/src/test/java/org/sonar/application/AppLoggingTest.java
index 4bc159a7af0..848f4bbc7c3 100644
--- a/sonar-application/src/test/java/org/sonar/application/AppLoggingTest.java
+++ b/sonar-application/src/test/java/org/sonar/application/AppLoggingTest.java
@@ -45,7 +45,7 @@ public class AppLoggingTest {
public TemporaryFolder temp = new TemporaryFolder();
Props props = new Props(new Properties());
- AppLogging sut = new AppLogging();
+ AppLogging underTest = new AppLogging();
@Before
public void setUp() throws Exception {
@@ -60,7 +60,7 @@ public class AppLoggingTest {
@Test
public void configure_defaults() {
- LoggerContext ctx = sut.configure(props);
+ LoggerContext ctx = underTest.configure(props);
Logger gobbler = ctx.getLogger(AppLogging.GOBBLER_LOGGER);
Appender<ILoggingEvent> appender = gobbler.getAppender(AppLogging.GOBBLER_APPENDER);
@@ -75,7 +75,7 @@ public class AppLoggingTest {
public void configure_no_rotation() {
props.set("sonar.log.rollingPolicy", "none");
- LoggerContext ctx = sut.configure(props);
+ LoggerContext ctx = underTest.configure(props);
Logger gobbler = ctx.getLogger(AppLogging.GOBBLER_LOGGER);
Appender<ILoggingEvent> appender = gobbler.getAppender(AppLogging.GOBBLER_APPENDER);
@@ -86,7 +86,7 @@ public class AppLoggingTest {
public void copyGobblerToConsole() {
props.set("sonar.log.console", "true");
- LoggerContext ctx = sut.configure(props);
+ LoggerContext ctx = underTest.configure(props);
Logger gobbler = ctx.getLogger(AppLogging.GOBBLER_LOGGER);
assertThat(gobbler.getAppender(AppLogging.GOBBLER_APPENDER)).isNotNull();
assertThat(gobbler.getAppender(AppLogging.CONSOLE_APPENDER)).isNotNull();
diff --git a/sonar-batch-protocol/src/main/protobuf/batch_report.proto b/sonar-batch-protocol/src/main/protobuf/batch_report.proto
index 08c5340d366..6632bb8a6f9 100644
--- a/sonar-batch-protocol/src/main/protobuf/batch_report.proto
+++ b/sonar-batch-protocol/src/main/protobuf/batch_report.proto
@@ -45,13 +45,21 @@ message Metadata {
optional string project_key = 2;
optional string branch = 3;
optional int32 root_component_ref = 4;
+}
+
+message ActiveRuleParameter {
+ optional string key = 1;
+ optional string value = 2;
+}
- /*
- Keys of the rules that were enabled in Quality profiles.
- A key is a string composed of the repository and the subKey, specific to the repository. Format is
- "{repository}:{subKey}", for instance "java:NullDereference".
- */
- repeated string active_rule_key = 5;
+/*
+ The rules that are enabled in the Quality profiles associated with the project
+*/
+message ActiveRule {
+ optional string rule_repository = 1;
+ optional string rule_key = 2;
+ optional Severity severity = 3;
+ repeated ActiveRuleParameter parameter = 4;
}
message ComponentLink {
diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java
index 805cda4dc4a..50afe349b6d 100644
--- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java
+++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java
@@ -42,12 +42,12 @@ public class BatchReportReaderTest {
File dir;
- BatchReportReader sut;
+ BatchReportReader underTest;
@Before
public void setUp() throws Exception {
dir = temp.newFolder();
- sut = new BatchReportReader(dir);
+ underTest = new BatchReportReader(dir);
}
@Test
@@ -59,7 +59,7 @@ public class BatchReportReaderTest {
.setRootComponentRef(1);
writer.writeMetadata(metadata.build());
- BatchReport.Metadata readMetadata = sut.readMetadata();
+ BatchReport.Metadata readMetadata = underTest.readMetadata();
assertThat(readMetadata.getAnalysisDate()).isEqualTo(15000000L);
assertThat(readMetadata.getProjectKey()).isEqualTo("PROJECT_A");
assertThat(readMetadata.getRootComponentRef()).isEqualTo(1);
@@ -67,7 +67,7 @@ public class BatchReportReaderTest {
@Test(expected = IllegalStateException.class)
public void fail_if_missing_metadata_file() {
- sut.readMetadata();
+ underTest.readMetadata();
}
@Test
@@ -78,12 +78,12 @@ public class BatchReportReaderTest {
.setPath("src/main/java/Foo.java");
writer.writeComponent(component.build());
- assertThat(sut.readComponent(1).getPath()).isEqualTo("src/main/java/Foo.java");
+ assertThat(underTest.readComponent(1).getPath()).isEqualTo("src/main/java/Foo.java");
}
@Test(expected = IllegalStateException.class)
public void fail_if_missing_file_on_component() {
- sut.readComponent(UNKNOWN_COMPONENT_REF);
+ underTest.readComponent(UNKNOWN_COMPONENT_REF);
}
@Test
@@ -94,13 +94,13 @@ public class BatchReportReaderTest {
.build();
writer.writeComponentIssues(1, Arrays.asList(issue));
- assertThat(sut.readComponentIssues(1)).hasSize(1);
- assertThat(sut.readComponentIssues(200)).isEmpty();
+ assertThat(underTest.readComponentIssues(1)).hasSize(1);
+ assertThat(underTest.readComponentIssues(200)).isEmpty();
}
@Test
public void empty_list_if_no_issue_found() {
- assertThat(sut.readComponentIssues(UNKNOWN_COMPONENT_REF)).isEmpty();
+ assertThat(underTest.readComponentIssues(UNKNOWN_COMPONENT_REF)).isEmpty();
}
@Test
@@ -110,13 +110,13 @@ public class BatchReportReaderTest {
.setStringValue("value_a");
writer.writeComponentMeasures(1, Arrays.asList(measure.build()));
- assertThat(sut.readComponentMeasures(1)).hasSize(1);
- assertThat(sut.readComponentMeasures(1).get(0).getStringValue()).isEqualTo("value_a");
+ assertThat(underTest.readComponentMeasures(1)).hasSize(1);
+ assertThat(underTest.readComponentMeasures(1).get(0).getStringValue()).isEqualTo("value_a");
}
@Test
public void empty_list_if_no_measure_found() {
- assertThat(sut.readComponentMeasures(UNKNOWN_COMPONENT_REF)).isEmpty();
+ assertThat(underTest.readComponentMeasures(UNKNOWN_COMPONENT_REF)).isEmpty();
}
@Test
@@ -127,13 +127,13 @@ public class BatchReportReaderTest {
.addChangeset(BatchReport.Changesets.Changeset.newBuilder().setDate(123_456_789).setAuthor("jack.daniels").setRevision("123-456-789"));
writer.writeComponentChangesets(scm.build());
- assertThat(sut.readChangesets(1).getChangesetList()).hasSize(1);
- assertThat(sut.readChangesets(1).getChangeset(0).getDate()).isEqualTo(123_456_789L);
+ assertThat(underTest.readChangesets(1).getChangesetList()).hasSize(1);
+ assertThat(underTest.readChangesets(1).getChangeset(0).getDate()).isEqualTo(123_456_789L);
}
@Test
public void null_if_no_changeset_found() {
- assertThat(sut.readChangesets(UNKNOWN_COMPONENT_REF)).isNull();
+ assertThat(underTest.readChangesets(UNKNOWN_COMPONENT_REF)).isNull();
}
@Test
@@ -160,15 +160,15 @@ public class BatchReportReaderTest {
.build();
writer.writeComponentDuplications(1, Arrays.asList(duplication));
- BatchReportReader sut = new BatchReportReader(dir);
- assertThat(sut.readComponentDuplications(1)).hasSize(1);
- assertThat(sut.readComponentDuplications(1).get(0).getOriginPosition()).isNotNull();
- assertThat(sut.readComponentDuplications(1).get(0).getDuplicateList()).hasSize(1);
+ BatchReportReader underTest = new BatchReportReader(dir);
+ assertThat(underTest.readComponentDuplications(1)).hasSize(1);
+ assertThat(underTest.readComponentDuplications(1).get(0).getOriginPosition()).isNotNull();
+ assertThat(underTest.readComponentDuplications(1).get(0).getDuplicateList()).hasSize(1);
}
@Test
public void empty_list_if_no_duplication_found() {
- assertThat(sut.readComponentDuplications(UNKNOWN_COMPONENT_REF)).isEmpty();
+ assertThat(underTest.readComponentDuplications(UNKNOWN_COMPONENT_REF)).isEmpty();
}
@Test
@@ -190,7 +190,7 @@ public class BatchReportReaderTest {
.build()
));
- try (InputStream inputStream = FileUtils.openInputStream(sut.readComponentSyntaxHighlighting(1))) {
+ try (InputStream inputStream = FileUtils.openInputStream(underTest.readComponentSyntaxHighlighting(1))) {
BatchReport.SyntaxHighlighting syntaxHighlighting = BatchReport.SyntaxHighlighting.PARSER.parseDelimitedFrom(inputStream);
assertThat(syntaxHighlighting.getRange()).isNotNull();
assertThat(syntaxHighlighting.getRange().getStartLine()).isEqualTo(1);
@@ -201,7 +201,7 @@ public class BatchReportReaderTest {
@Test
public void return_null_if_no_highlighting_found() {
- assertThat(sut.readComponentSyntaxHighlighting(UNKNOWN_COMPONENT_REF)).isNull();
+ assertThat(underTest.readComponentSyntaxHighlighting(UNKNOWN_COMPONENT_REF)).isNull();
}
@Test
@@ -228,15 +228,15 @@ public class BatchReportReaderTest {
.build())
.build()));
- sut = new BatchReportReader(dir);
- assertThat(sut.readComponentSymbols(1)).hasSize(1);
- assertThat(sut.readComponentSymbols(1).get(0).getDeclaration().getStartLine()).isEqualTo(1);
- assertThat(sut.readComponentSymbols(1).get(0).getReference(0).getStartLine()).isEqualTo(10);
+ underTest = new BatchReportReader(dir);
+ assertThat(underTest.readComponentSymbols(1)).hasSize(1);
+ assertThat(underTest.readComponentSymbols(1).get(0).getDeclaration().getStartLine()).isEqualTo(1);
+ assertThat(underTest.readComponentSymbols(1).get(0).getReference(0).getStartLine()).isEqualTo(10);
}
@Test
public void empty_list_if_no_symbol_found() {
- assertThat(sut.readComponentSymbols(UNKNOWN_COMPONENT_REF)).isEmpty();
+ assertThat(underTest.readComponentSymbols(UNKNOWN_COMPONENT_REF)).isEmpty();
}
@Test
@@ -268,7 +268,7 @@ public class BatchReportReaderTest {
.setOverallCoveredConditions(5)
.build()));
- sut = new BatchReportReader(dir);
+ underTest = new BatchReportReader(dir);
try (InputStream inputStream = FileUtils.openInputStream(new BatchReportReader(dir).readComponentCoverage(1))) {
BatchReport.Coverage coverage = BatchReport.Coverage.PARSER.parseDelimitedFrom(inputStream);
@@ -293,7 +293,7 @@ public class BatchReportReaderTest {
@Test
public void return_null_if_no_coverage_found() {
- assertThat(sut.readComponentCoverage(UNKNOWN_COMPONENT_REF)).isNull();
+ assertThat(underTest.readComponentCoverage(UNKNOWN_COMPONENT_REF)).isNull();
}
@Test
@@ -317,7 +317,7 @@ public class BatchReportReaderTest {
.setStatus(Constants.TestStatus.OK)
.build()));
- try (InputStream inputStream = FileUtils.openInputStream(sut.readTests(1))) {
+ try (InputStream inputStream = FileUtils.openInputStream(underTest.readTests(1))) {
BatchReport.Test testResult = BatchReport.Test.PARSER.parseDelimitedFrom(inputStream);
assertThat(testResult.getDurationInMs()).isEqualTo(60_000);
assertThat(testResult.getStacktrace()).isEqualTo("stacktrace");
@@ -328,7 +328,7 @@ public class BatchReportReaderTest {
@Test
public void null_if_no_test_found() {
- assertThat(sut.readTests(UNKNOWN_COMPONENT_REF)).isNull();
+ assertThat(underTest.readTests(UNKNOWN_COMPONENT_REF)).isNull();
}
@Test
@@ -344,7 +344,7 @@ public class BatchReportReaderTest {
.build()
));
- try (InputStream inputStream = FileUtils.openInputStream(sut.readCoverageDetails(1))) {
+ try (InputStream inputStream = FileUtils.openInputStream(underTest.readCoverageDetails(1))) {
BatchReport.CoverageDetail coverageDetail = BatchReport.CoverageDetail.PARSER.parseDelimitedFrom(inputStream);
assertThat(coverageDetail.getTestName()).isEqualTo("test-name");
assertThat(coverageDetail.getCoveredFile(0).getFileRef()).isEqualTo(2);
@@ -354,7 +354,7 @@ public class BatchReportReaderTest {
@Test
public void null_if_no_coverage_detail_found() {
- assertThat(sut.readCoverageDetails(UNKNOWN_COMPONENT_REF)).isNull();
+ assertThat(underTest.readCoverageDetails(UNKNOWN_COMPONENT_REF)).isNull();
}
}
diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java
index cf33a8f6d8f..18716f7332f 100644
--- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java
+++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java
@@ -38,18 +38,18 @@ public class BatchReportWriterTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
File dir;
- BatchReportWriter sut;
+ BatchReportWriter underTest;
@Before
public void setUp() throws Exception {
dir = temp.newFolder();
- sut = new BatchReportWriter(dir);
+ underTest = new BatchReportWriter(dir);
}
@Test
public void create_dir_if_does_not_exist() {
FileUtils.deleteQuietly(dir);
- sut = new BatchReportWriter(dir);
+ underTest = new BatchReportWriter(dir);
assertThat(dir).isDirectory().exists();
}
@@ -60,9 +60,9 @@ public class BatchReportWriterTest {
.setAnalysisDate(15000000L)
.setProjectKey("PROJECT_A")
.setRootComponentRef(1);
- sut.writeMetadata(metadata.build());
+ underTest.writeMetadata(metadata.build());
- BatchReport.Metadata read = ProtobufUtil.readFile(sut.getFileStructure().metadataFile(), BatchReport.Metadata.PARSER);
+ BatchReport.Metadata read = ProtobufUtil.readFile(underTest.getFileStructure().metadataFile(), BatchReport.Metadata.PARSER);
assertThat(read.getAnalysisDate()).isEqualTo(15000000L);
assertThat(read.getProjectKey()).isEqualTo("PROJECT_A");
assertThat(read.getRootComponentRef()).isEqualTo(1);
@@ -71,7 +71,7 @@ public class BatchReportWriterTest {
@Test
public void write_component() {
// no data yet
- assertThat(sut.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isFalse();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isFalse();
// write data
BatchReport.Component.Builder component = BatchReport.Component.newBuilder()
@@ -82,10 +82,10 @@ public class BatchReportWriterTest {
.setIsTest(false)
.addChildRef(5)
.addChildRef(42);
- sut.writeComponent(component.build());
+ underTest.writeComponent(component.build());
- assertThat(sut.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isTrue();
- File file = sut.getFileStructure().fileFor(FileStructure.Domain.COMPONENT, 1);
+ assertThat(underTest.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isTrue();
+ File file = underTest.getFileStructure().fileFor(FileStructure.Domain.COMPONENT, 1);
assertThat(file).exists().isFile();
BatchReport.Component read = ProtobufUtil.readFile(file, BatchReport.Component.PARSER);
assertThat(read.getRef()).isEqualTo(1);
@@ -97,7 +97,7 @@ public class BatchReportWriterTest {
@Test
public void write_issues() {
// no data yet
- assertThat(sut.hasComponentData(FileStructure.Domain.ISSUES, 1)).isFalse();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.ISSUES, 1)).isFalse();
// write data
BatchReport.Issue issue = BatchReport.Issue.newBuilder()
@@ -105,10 +105,10 @@ public class BatchReportWriterTest {
.setMsg("the message")
.build();
- sut.writeComponentIssues(1, Arrays.asList(issue));
+ underTest.writeComponentIssues(1, Arrays.asList(issue));
- assertThat(sut.hasComponentData(FileStructure.Domain.ISSUES, 1)).isTrue();
- File file = sut.getFileStructure().fileFor(FileStructure.Domain.ISSUES, 1);
+ assertThat(underTest.hasComponentData(FileStructure.Domain.ISSUES, 1)).isTrue();
+ File file = underTest.getFileStructure().fileFor(FileStructure.Domain.ISSUES, 1);
assertThat(file).exists().isFile();
BatchReport.Issues read = ProtobufUtil.readFile(file, BatchReport.Issues.PARSER);
assertThat(read.getComponentRef()).isEqualTo(1);
@@ -117,7 +117,7 @@ public class BatchReportWriterTest {
@Test
public void write_measures() {
- assertThat(sut.hasComponentData(FileStructure.Domain.MEASURES, 1)).isFalse();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.MEASURES, 1)).isFalse();
BatchReport.Measure measure = BatchReport.Measure.newBuilder()
.setStringValue("text-value")
@@ -126,10 +126,10 @@ public class BatchReportWriterTest {
.setDescription("description")
.build();
- sut.writeComponentMeasures(1, Arrays.asList(measure));
+ underTest.writeComponentMeasures(1, Arrays.asList(measure));
- assertThat(sut.hasComponentData(FileStructure.Domain.MEASURES, 1)).isTrue();
- File file = sut.getFileStructure().fileFor(FileStructure.Domain.MEASURES, 1);
+ assertThat(underTest.hasComponentData(FileStructure.Domain.MEASURES, 1)).isTrue();
+ File file = underTest.getFileStructure().fileFor(FileStructure.Domain.MEASURES, 1);
assertThat(file).exists().isFile();
BatchReport.Measures measures = ProtobufUtil.readFile(file, BatchReport.Measures.PARSER);
assertThat(measures.getComponentRef()).isEqualTo(1);
@@ -142,7 +142,7 @@ public class BatchReportWriterTest {
@Test
public void write_scm() {
- assertThat(sut.hasComponentData(FileStructure.Domain.CHANGESETS, 1)).isFalse();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.CHANGESETS, 1)).isFalse();
BatchReport.Changesets scm = BatchReport.Changesets.newBuilder()
.setComponentRef(1)
@@ -153,10 +153,10 @@ public class BatchReportWriterTest {
.setDate(123_456_789L))
.build();
- sut.writeComponentChangesets(scm);
+ underTest.writeComponentChangesets(scm);
- assertThat(sut.hasComponentData(FileStructure.Domain.CHANGESETS, 1)).isTrue();
- File file = sut.getFileStructure().fileFor(FileStructure.Domain.CHANGESETS, 1);
+ assertThat(underTest.hasComponentData(FileStructure.Domain.CHANGESETS, 1)).isTrue();
+ File file = underTest.getFileStructure().fileFor(FileStructure.Domain.CHANGESETS, 1);
assertThat(file).exists().isFile();
BatchReport.Changesets read = ProtobufUtil.readFile(file, BatchReport.Changesets.PARSER);
assertThat(read.getComponentRef()).isEqualTo(1);
@@ -167,7 +167,7 @@ public class BatchReportWriterTest {
@Test
public void write_duplications() {
- assertThat(sut.hasComponentData(FileStructure.Domain.DUPLICATIONS, 1)).isFalse();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.DUPLICATIONS, 1)).isFalse();
BatchReport.Duplication duplication = BatchReport.Duplication.newBuilder()
.setOriginPosition(Range.newBuilder()
@@ -183,10 +183,10 @@ public class BatchReportWriterTest {
.build())
.build())
.build();
- sut.writeComponentDuplications(1, Arrays.asList(duplication));
+ underTest.writeComponentDuplications(1, Arrays.asList(duplication));
- assertThat(sut.hasComponentData(FileStructure.Domain.DUPLICATIONS, 1)).isTrue();
- File file = sut.getFileStructure().fileFor(FileStructure.Domain.DUPLICATIONS, 1);
+ assertThat(underTest.hasComponentData(FileStructure.Domain.DUPLICATIONS, 1)).isTrue();
+ File file = underTest.getFileStructure().fileFor(FileStructure.Domain.DUPLICATIONS, 1);
assertThat(file).exists().isFile();
BatchReport.Duplications duplications = ProtobufUtil.readFile(file, BatchReport.Duplications.PARSER);
assertThat(duplications.getComponentRef()).isEqualTo(1);
@@ -198,7 +198,7 @@ public class BatchReportWriterTest {
@Test
public void write_symbols() {
// no data yet
- assertThat(sut.hasComponentData(FileStructure.Domain.SYMBOLS, 1)).isFalse();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.SYMBOLS, 1)).isFalse();
// write data
BatchReport.Symbols.Symbol symbol = BatchReport.Symbols.Symbol.newBuilder()
@@ -216,11 +216,11 @@ public class BatchReportWriterTest {
.build())
.build();
- sut.writeComponentSymbols(1, Arrays.asList(symbol));
+ underTest.writeComponentSymbols(1, Arrays.asList(symbol));
- assertThat(sut.hasComponentData(FileStructure.Domain.SYMBOLS, 1)).isTrue();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.SYMBOLS, 1)).isTrue();
- File file = sut.getFileStructure().fileFor(FileStructure.Domain.SYMBOLS, 1);
+ File file = underTest.getFileStructure().fileFor(FileStructure.Domain.SYMBOLS, 1);
assertThat(file).exists().isFile();
BatchReport.Symbols read = ProtobufUtil.readFile(file, BatchReport.Symbols.PARSER);
assertThat(read.getFileRef()).isEqualTo(1);
@@ -232,9 +232,9 @@ public class BatchReportWriterTest {
@Test
public void write_syntax_highlighting() {
// no data yet
- assertThat(sut.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, 1)).isFalse();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, 1)).isFalse();
- sut.writeComponentSyntaxHighlighting(1, Arrays.asList(
+ underTest.writeComponentSyntaxHighlighting(1, Arrays.asList(
BatchReport.SyntaxHighlighting.newBuilder()
.setRange(BatchReport.Range.newBuilder()
.setStartLine(1)
@@ -242,17 +242,17 @@ public class BatchReportWriterTest {
.build())
.setType(Constants.HighlightingType.ANNOTATION)
.build()
- ));
+ ));
- assertThat(sut.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, 1)).isTrue();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, 1)).isTrue();
}
@Test
public void write_coverage() {
// no data yet
- assertThat(sut.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isFalse();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isFalse();
- sut.writeComponentCoverage(1, Arrays.asList(
+ underTest.writeComponentCoverage(1, Arrays.asList(
BatchReport.Coverage.newBuilder()
.setLine(1)
.setConditions(1)
@@ -262,31 +262,31 @@ public class BatchReportWriterTest {
.setItCoveredConditions(1)
.setOverallCoveredConditions(1)
.build()
- ));
+ ));
- assertThat(sut.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isTrue();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isTrue();
}
@Test
public void write_tests() {
- assertThat(sut.hasComponentData(FileStructure.Domain.TESTS, 1)).isFalse();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.TESTS, 1)).isFalse();
- sut.writeTests(1, Arrays.asList(
+ underTest.writeTests(1, Arrays.asList(
BatchReport.Test.getDefaultInstance()
- ));
+ ));
- assertThat(sut.hasComponentData(FileStructure.Domain.TESTS, 1)).isTrue();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.TESTS, 1)).isTrue();
}
@Test
public void write_coverage_details() {
- assertThat(sut.hasComponentData(FileStructure.Domain.COVERAGE_DETAILS, 1)).isFalse();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGE_DETAILS, 1)).isFalse();
- sut.writeCoverageDetails(1, Arrays.asList(
+ underTest.writeCoverageDetails(1, Arrays.asList(
BatchReport.CoverageDetail.getDefaultInstance()
- ));
+ ));
- assertThat(sut.hasComponentData(FileStructure.Domain.COVERAGE_DETAILS, 1)).isTrue();
+ assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGE_DETAILS, 1)).isTrue();
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/util/NonNullInputFunctionTest.java b/sonar-core/src/test/java/org/sonar/core/util/NonNullInputFunctionTest.java
index 090e71414a6..d80971fcf5a 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/NonNullInputFunctionTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/NonNullInputFunctionTest.java
@@ -26,12 +26,12 @@ import static org.junit.Assert.fail;
public class NonNullInputFunctionTest {
- NonNullInputFunction<String, Integer> sut = new TestFunction();
+ NonNullInputFunction<String, Integer> underTest = new TestFunction();
@Test
public void fail_if_null_input() {
try {
- sut.apply(null);
+ underTest.apply(null);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("Null inputs are not allowed in this function");
@@ -40,7 +40,7 @@ public class NonNullInputFunctionTest {
@Test
public void apply() {
- assertThat(sut.apply("foo")).isEqualTo(3);
+ assertThat(underTest.apply("foo")).isEqualTo(3);
}
private static class TestFunction extends NonNullInputFunction<String, Integer> {
diff --git a/sonar-db/src/test/java/org/sonar/db/activity/ActivityDaoTest.java b/sonar-db/src/test/java/org/sonar/db/activity/ActivityDaoTest.java
index c2135f6e3ac..13406d5be9e 100644
--- a/sonar-db/src/test/java/org/sonar/db/activity/ActivityDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/activity/ActivityDaoTest.java
@@ -39,7 +39,7 @@ public class ActivityDaoTest {
@Rule
public DbTester dbTester = DbTester.create(system);
- ActivityDao sut = dbTester.getDbClient().activityDao();
+ ActivityDao underTest = dbTester.getDbClient().activityDao();
@Test
public void insert() {
@@ -47,7 +47,7 @@ public class ActivityDaoTest {
ActivityDto dto = new ActivityDto()
.setKey("UUID_1").setAction("THE_ACTION").setType("THE_TYPE")
.setAuthor("THE_AUTHOR").setData("THE_DATA");
- sut.insert(dto);
+ underTest.insert(dto);
Map<String, Object> map = dbTester.selectFirst("select created_at as \"createdAt\", log_action as \"action\", data_field as \"data\" from activities where log_key='UUID_1'");
assertThat(map.get("action")).isEqualTo("THE_ACTION");
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
index b1e97c6ea72..dde4347b69c 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
@@ -45,13 +45,13 @@ public class ComponentDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- ComponentDao sut = new ComponentDao();
+ ComponentDao underTest = new ComponentDao();
@Test
public void get_by_uuid() {
db.prepareDbUnit(getClass(), "shared.xml");
- ComponentDto result = sut.selectByUuid(db.getSession(), "KLMN").get();
+ ComponentDto result = underTest.selectByUuid(db.getSession(), "KLMN").get();
assertThat(result).isNotNull();
assertThat(result.uuid()).isEqualTo("KLMN");
assertThat(result.moduleUuid()).isEqualTo("EFGH");
@@ -67,14 +67,14 @@ public class ComponentDaoTest {
assertThat(result.language()).isEqualTo("java");
assertThat(result.getCopyResourceId()).isNull();
- assertThat(sut.selectByUuid(db.getSession(), "UNKNOWN")).isAbsent();
+ assertThat(underTest.selectByUuid(db.getSession(), "UNKNOWN")).isAbsent();
}
@Test
public void get_by_uuid_on_technical_project_copy() {
db.prepareDbUnit(getClass(), "shared.xml");
- ComponentDto result = sut.selectByUuid(db.getSession(), "STUV").get();
+ ComponentDto result = underTest.selectByUuid(db.getSession(), "STUV").get();
assertThat(result).isNotNull();
assertThat(result.uuid()).isEqualTo("STUV");
assertThat(result.moduleUuid()).isEqualTo("OPQR");
@@ -95,7 +95,7 @@ public class ComponentDaoTest {
public void get_by_uuid_on_disabled_component() {
db.prepareDbUnit(getClass(), "shared.xml");
- ComponentDto result = sut.selectByUuid(db.getSession(), "DCBA").get();
+ ComponentDto result = underTest.selectByUuid(db.getSession(), "DCBA").get();
assertThat(result).isNotNull();
assertThat(result.isEnabled()).isFalse();
}
@@ -106,14 +106,14 @@ public class ComponentDaoTest {
db.prepareDbUnit(getClass(), "shared.xml");
- sut.selectNonNullByUuid(db.getSession(), "unknown");
+ underTest.selectNonNullByUuid(db.getSession(), "unknown");
}
@Test
public void get_by_key() {
db.prepareDbUnit(getClass(), "shared.xml");
- Optional<ComponentDto> optional = sut.selectByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java");
+ Optional<ComponentDto> optional = underTest.selectByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(optional).isPresent();
ComponentDto result = optional.get();
@@ -126,7 +126,7 @@ public class ComponentDaoTest {
assertThat(result.language()).isEqualTo("java");
assertThat(result.parentProjectId()).isEqualTo(2);
- assertThat(sut.selectByKey(db.getSession(), "unknown")).isAbsent();
+ assertThat(underTest.selectByKey(db.getSession(), "unknown")).isAbsent();
}
@Test
@@ -135,14 +135,14 @@ public class ComponentDaoTest {
db.prepareDbUnit(getClass(), "shared.xml");
- sut.selectNonNullByKey(db.getSession(), "unknown");
+ underTest.selectNonNullByKey(db.getSession(), "unknown");
}
@Test
public void get_by_key_on_disabled_component() {
db.prepareDbUnit(getClass(), "shared.xml");
- ComponentDto result = sut.selectNonNullByKey(db.getSession(), "org.disabled.project");
+ ComponentDto result = underTest.selectNonNullByKey(db.getSession(), "org.disabled.project");
assertThat(result.isEnabled()).isFalse();
}
@@ -150,7 +150,7 @@ public class ComponentDaoTest {
public void get_by_key_on_a_root_project() {
db.prepareDbUnit(getClass(), "shared.xml");
- ComponentDto result = sut.selectNonNullByKey(db.getSession(), "org.struts:struts");
+ ComponentDto result = underTest.selectNonNullByKey(db.getSession(), "org.struts:struts");
assertThat(result.key()).isEqualTo("org.struts:struts");
assertThat(result.deprecatedKey()).isEqualTo("org.struts:struts");
assertThat(result.path()).isNull();
@@ -168,7 +168,7 @@ public class ComponentDaoTest {
public void get_by_keys() {
db.prepareDbUnit(getClass(), "shared.xml");
- List<ComponentDto> results = sut.selectByKeys(db.getSession(), Collections.singletonList("org.struts:struts-core:src/org/struts/RequestContext.java"));
+ List<ComponentDto> results = underTest.selectByKeys(db.getSession(), Collections.singletonList("org.struts:struts-core:src/org/struts/RequestContext.java"));
assertThat(results).hasSize(1);
ComponentDto result = results.get(0);
@@ -182,14 +182,14 @@ public class ComponentDaoTest {
assertThat(result.language()).isEqualTo("java");
assertThat(result.parentProjectId()).isEqualTo(2);
- assertThat(sut.selectByKeys(db.getSession(), Collections.singletonList("unknown"))).isEmpty();
+ assertThat(underTest.selectByKeys(db.getSession(), Collections.singletonList("unknown"))).isEmpty();
}
@Test
public void get_by_ids() {
db.prepareDbUnit(getClass(), "shared.xml");
- List<ComponentDto> results = sut.selectByIds(db.getSession(), newArrayList(4L));
+ List<ComponentDto> results = underTest.selectByIds(db.getSession(), newArrayList(4L));
assertThat(results).hasSize(1);
ComponentDto result = results.get(0);
@@ -203,14 +203,14 @@ public class ComponentDaoTest {
assertThat(result.language()).isEqualTo("java");
assertThat(result.parentProjectId()).isEqualTo(2);
- assertThat(sut.selectByIds(db.getSession(), newArrayList(555L))).isEmpty();
+ assertThat(underTest.selectByIds(db.getSession(), newArrayList(555L))).isEmpty();
}
@Test
public void get_by_uuids() {
db.prepareDbUnit(getClass(), "shared.xml");
- List<ComponentDto> results = sut.selectByUuids(db.getSession(), newArrayList("KLMN"));
+ List<ComponentDto> results = underTest.selectByUuids(db.getSession(), newArrayList("KLMN"));
assertThat(results).hasSize(1);
ComponentDto result = results.get(0);
@@ -228,14 +228,14 @@ public class ComponentDaoTest {
assertThat(result.scope()).isEqualTo("FIL");
assertThat(result.language()).isEqualTo("java");
- assertThat(sut.selectByUuids(db.getSession(), newArrayList("unknown"))).isEmpty();
+ assertThat(underTest.selectByUuids(db.getSession(), newArrayList("unknown"))).isEmpty();
}
@Test
public void get_by_uuids_on_removed_components() {
db.prepareDbUnit(getClass(), "shared.xml");
- List<ComponentDto> results = sut.selectByUuids(db.getSession(), newArrayList("DCBA"));
+ List<ComponentDto> results = underTest.selectByUuids(db.getSession(), newArrayList("DCBA"));
assertThat(results).hasSize(1);
ComponentDto result = results.get(0);
@@ -247,25 +247,25 @@ public class ComponentDaoTest {
public void select_existing_uuids() {
db.prepareDbUnit(getClass(), "shared.xml");
- List<String> results = sut.selectExistingUuids(db.getSession(), newArrayList("KLMN"));
+ List<String> results = underTest.selectExistingUuids(db.getSession(), newArrayList("KLMN"));
assertThat(results).containsOnly("KLMN");
- assertThat(sut.selectExistingUuids(db.getSession(), newArrayList("KLMN", "unknown"))).hasSize(1);
- assertThat(sut.selectExistingUuids(db.getSession(), newArrayList("unknown"))).isEmpty();
+ assertThat(underTest.selectExistingUuids(db.getSession(), newArrayList("KLMN", "unknown"))).hasSize(1);
+ assertThat(underTest.selectExistingUuids(db.getSession(), newArrayList("unknown"))).isEmpty();
}
@Test
public void get_by_id() {
db.prepareDbUnit(getClass(), "shared.xml");
- assertThat(sut.selectNonNullById(db.getSession(), 4L)).isNotNull();
+ assertThat(underTest.selectNonNullById(db.getSession(), 4L)).isNotNull();
}
@Test
public void get_by_id_on_disabled_component() {
db.prepareDbUnit(getClass(), "shared.xml");
- Optional<ComponentDto> result = sut.selectById(db.getSession(), 10L);
+ Optional<ComponentDto> result = underTest.selectById(db.getSession(), 10L);
assertThat(result).isPresent();
assertThat(result.get().isEnabled()).isFalse();
}
@@ -274,23 +274,23 @@ public class ComponentDaoTest {
public void fail_to_get_by_id_when_project_not_found() {
db.prepareDbUnit(getClass(), "shared.xml");
- sut.selectNonNullById(db.getSession(), 111L);
+ underTest.selectNonNullById(db.getSession(), 111L);
}
@Test
public void get_nullable_by_id() {
db.prepareDbUnit(getClass(), "shared.xml");
- assertThat(sut.selectById(db.getSession(), 4L)).isPresent();
- assertThat(sut.selectById(db.getSession(), 111L)).isAbsent();
+ assertThat(underTest.selectById(db.getSession(), 4L)).isPresent();
+ assertThat(underTest.selectById(db.getSession(), 111L)).isAbsent();
}
@Test
public void count_by_id() {
db.prepareDbUnit(getClass(), "shared.xml");
- assertThat(sut.existsById(4L, db.getSession())).isTrue();
- assertThat(sut.existsById(111L, db.getSession())).isFalse();
+ assertThat(underTest.existsById(4L, db.getSession())).isTrue();
+ assertThat(underTest.existsById(111L, db.getSession())).isFalse();
}
@Test
@@ -298,34 +298,34 @@ public class ComponentDaoTest {
db.prepareDbUnit(getClass(), "multi-modules.xml");
// Sub project of a file
- List<ComponentDto> results = sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("HIJK"));
+ List<ComponentDto> results = underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("HIJK"));
assertThat(results).hasSize(1);
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts-data");
// Sub project of a directory
- results = sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("GHIJ"));
+ results = underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("GHIJ"));
assertThat(results).hasSize(1);
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts-data");
// Sub project of a sub module
- results = sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("FGHI"));
+ results = underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("FGHI"));
assertThat(results).hasSize(1);
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts");
// Sub project of a module
- results = sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("EFGH"));
+ results = underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("EFGH"));
assertThat(results).hasSize(1);
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts");
// Sub project of a project
- assertThat(sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("ABCD"))).isEmpty();
+ assertThat(underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("ABCD"))).isEmpty();
// SUb projects of a component and a sub module
- assertThat(sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("HIJK", "FGHI"))).hasSize(2);
+ assertThat(underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("HIJK", "FGHI"))).hasSize(2);
- assertThat(sut.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("unknown"))).isEmpty();
+ assertThat(underTest.selectSubProjectsByComponentUuids(db.getSession(), newArrayList("unknown"))).isEmpty();
- assertThat(sut.selectSubProjectsByComponentUuids(db.getSession(), Collections.<String>emptyList())).isEmpty();
+ assertThat(underTest.selectSubProjectsByComponentUuids(db.getSession(), Collections.<String>emptyList())).isEmpty();
}
@Test
@@ -333,20 +333,20 @@ public class ComponentDaoTest {
db.prepareDbUnit(getClass(), "multi-modules.xml");
// From root project
- List<ComponentDto> modules = sut.selectEnabledDescendantModules(db.getSession(), "ABCD");
+ List<ComponentDto> modules = underTest.selectEnabledDescendantModules(db.getSession(), "ABCD");
assertThat(modules).extracting("uuid").containsOnly("ABCD", "EFGH", "FGHI");
// From module
- modules = sut.selectEnabledDescendantModules(db.getSession(), "EFGH");
+ modules = underTest.selectEnabledDescendantModules(db.getSession(), "EFGH");
assertThat(modules).extracting("uuid").containsOnly("EFGH", "FGHI");
// From sub module
- modules = sut.selectEnabledDescendantModules(db.getSession(), "FGHI");
+ modules = underTest.selectEnabledDescendantModules(db.getSession(), "FGHI");
assertThat(modules).extracting("uuid").containsOnly("FGHI");
// Folder
- assertThat(sut.selectEnabledDescendantModules(db.getSession(), "GHIJ")).isEmpty();
- assertThat(sut.selectEnabledDescendantModules(db.getSession(), "unknown")).isEmpty();
+ assertThat(underTest.selectEnabledDescendantModules(db.getSession(), "GHIJ")).isEmpty();
+ assertThat(underTest.selectEnabledDescendantModules(db.getSession(), "unknown")).isEmpty();
}
@Test
@@ -354,15 +354,15 @@ public class ComponentDaoTest {
db.prepareDbUnit(getClass(), "multi-modules.xml");
// From root project, disabled sub module is returned
- List<ComponentDto> modules = sut.selectDescendantModules(db.getSession(), "ABCD");
+ List<ComponentDto> modules = underTest.selectDescendantModules(db.getSession(), "ABCD");
assertThat(modules).extracting("uuid").containsOnly("ABCD", "EFGH", "FGHI", "IHGF");
// From module, disabled sub module is returned
- modules = sut.selectDescendantModules(db.getSession(), "EFGH");
+ modules = underTest.selectDescendantModules(db.getSession(), "EFGH");
assertThat(modules).extracting("uuid").containsOnly("EFGH", "FGHI", "IHGF");
// From removed sub module -> should not be returned
- assertThat(sut.selectDescendantModules(db.getSession(), "IHGF")).isEmpty();
+ assertThat(underTest.selectDescendantModules(db.getSession(), "IHGF")).isEmpty();
}
@Test
@@ -370,30 +370,30 @@ public class ComponentDaoTest {
db.prepareDbUnit(getClass(), "select_module_files_tree.xml");
// From root project
- List<FilePathWithHashDto> files = sut.selectEnabledDescendantFiles(db.getSession(), "ABCD");
+ List<FilePathWithHashDto> files = underTest.selectEnabledDescendantFiles(db.getSession(), "ABCD");
assertThat(files).extracting("uuid").containsOnly("EFGHI", "HIJK");
assertThat(files).extracting("moduleUuid").containsOnly("EFGH", "FGHI");
assertThat(files).extracting("srcHash").containsOnly("srcEFGHI", "srcHIJK");
assertThat(files).extracting("path").containsOnly("src/org/struts/pom.xml", "src/org/struts/RequestContext.java");
// From module
- files = sut.selectEnabledDescendantFiles(db.getSession(), "EFGH");
+ files = underTest.selectEnabledDescendantFiles(db.getSession(), "EFGH");
assertThat(files).extracting("uuid").containsOnly("EFGHI", "HIJK");
assertThat(files).extracting("moduleUuid").containsOnly("EFGH", "FGHI");
assertThat(files).extracting("srcHash").containsOnly("srcEFGHI", "srcHIJK");
assertThat(files).extracting("path").containsOnly("src/org/struts/pom.xml", "src/org/struts/RequestContext.java");
// From sub module
- files = sut.selectEnabledDescendantFiles(db.getSession(), "FGHI");
+ files = underTest.selectEnabledDescendantFiles(db.getSession(), "FGHI");
assertThat(files).extracting("uuid").containsOnly("HIJK");
assertThat(files).extracting("moduleUuid").containsOnly("FGHI");
assertThat(files).extracting("srcHash").containsOnly("srcHIJK");
assertThat(files).extracting("path").containsOnly("src/org/struts/RequestContext.java");
// From directory
- assertThat(sut.selectEnabledDescendantFiles(db.getSession(), "GHIJ")).isEmpty();
+ assertThat(underTest.selectEnabledDescendantFiles(db.getSession(), "GHIJ")).isEmpty();
- assertThat(sut.selectEnabledDescendantFiles(db.getSession(), "unknown")).isEmpty();
+ assertThat(underTest.selectEnabledDescendantFiles(db.getSession(), "unknown")).isEmpty();
}
@Test
@@ -401,69 +401,69 @@ public class ComponentDaoTest {
db.prepareDbUnit(getClass(), "select_module_files_tree.xml");
// From root project
- List<FilePathWithHashDto> files = sut.selectEnabledFilesFromProject(db.getSession(), "ABCD");
+ List<FilePathWithHashDto> files = underTest.selectEnabledFilesFromProject(db.getSession(), "ABCD");
assertThat(files).extracting("uuid").containsOnly("EFGHI", "HIJK");
assertThat(files).extracting("moduleUuid").containsOnly("EFGH", "FGHI");
assertThat(files).extracting("srcHash").containsOnly("srcEFGHI", "srcHIJK");
assertThat(files).extracting("path").containsOnly("src/org/struts/pom.xml", "src/org/struts/RequestContext.java");
// From module
- assertThat(sut.selectEnabledFilesFromProject(db.getSession(), "EFGH")).isEmpty();
+ assertThat(underTest.selectEnabledFilesFromProject(db.getSession(), "EFGH")).isEmpty();
// From sub module
- assertThat(sut.selectEnabledFilesFromProject(db.getSession(), "FGHI")).isEmpty();
+ assertThat(underTest.selectEnabledFilesFromProject(db.getSession(), "FGHI")).isEmpty();
// From directory
- assertThat(sut.selectEnabledFilesFromProject(db.getSession(), "GHIJ")).isEmpty();
+ assertThat(underTest.selectEnabledFilesFromProject(db.getSession(), "GHIJ")).isEmpty();
- assertThat(sut.selectEnabledFilesFromProject(db.getSession(), "unknown")).isEmpty();
+ assertThat(underTest.selectEnabledFilesFromProject(db.getSession(), "unknown")).isEmpty();
}
@Test
public void select_all_components_from_project() {
db.prepareDbUnit(getClass(), "multi-modules.xml");
- List<ComponentDto> components = sut.selectAllComponentsFromProjectKey(db.getSession(), "org.struts:struts");
+ List<ComponentDto> components = underTest.selectAllComponentsFromProjectKey(db.getSession(), "org.struts:struts");
// Removed components are included
assertThat(components).hasSize(8);
- assertThat(sut.selectAllComponentsFromProjectKey(db.getSession(), "UNKNOWN")).isEmpty();
+ assertThat(underTest.selectAllComponentsFromProjectKey(db.getSession(), "UNKNOWN")).isEmpty();
}
@Test
public void select_modules_from_project() {
db.prepareDbUnit(getClass(), "multi-modules.xml");
- List<ComponentDto> components = sut.selectEnabledModulesFromProjectKey(db.getSession(), "org.struts:struts");
+ List<ComponentDto> components = underTest.selectEnabledModulesFromProjectKey(db.getSession(), "org.struts:struts");
assertThat(components).hasSize(3);
- assertThat(sut.selectEnabledModulesFromProjectKey(db.getSession(), "UNKNOWN")).isEmpty();
+ assertThat(underTest.selectEnabledModulesFromProjectKey(db.getSession(), "UNKNOWN")).isEmpty();
}
@Test
public void select_views_and_sub_views() {
db.prepareDbUnit(getClass(), "shared_views.xml");
- assertThat(sut.selectAllViewsAndSubViews(db.getSession())).extracting("uuid").containsOnly("ABCD", "EFGH", "FGHI", "IJKL");
- assertThat(sut.selectAllViewsAndSubViews(db.getSession())).extracting("projectUuid").containsOnly("ABCD", "EFGH", "IJKL");
+ assertThat(underTest.selectAllViewsAndSubViews(db.getSession())).extracting("uuid").containsOnly("ABCD", "EFGH", "FGHI", "IJKL");
+ assertThat(underTest.selectAllViewsAndSubViews(db.getSession())).extracting("projectUuid").containsOnly("ABCD", "EFGH", "IJKL");
}
@Test
public void select_projects_from_view() {
db.prepareDbUnit(getClass(), "shared_views.xml");
- assertThat(sut.selectProjectsFromView(db.getSession(), "ABCD", "ABCD")).containsOnly("JKLM");
- assertThat(sut.selectProjectsFromView(db.getSession(), "EFGH", "EFGH")).containsOnly("KLMN", "JKLM");
- assertThat(sut.selectProjectsFromView(db.getSession(), "FGHI", "EFGH")).containsOnly("JKLM");
- assertThat(sut.selectProjectsFromView(db.getSession(), "IJKL", "IJKL")).isEmpty();
- assertThat(sut.selectProjectsFromView(db.getSession(), "Unknown", "Unknown")).isEmpty();
+ assertThat(underTest.selectProjectsFromView(db.getSession(), "ABCD", "ABCD")).containsOnly("JKLM");
+ assertThat(underTest.selectProjectsFromView(db.getSession(), "EFGH", "EFGH")).containsOnly("KLMN", "JKLM");
+ assertThat(underTest.selectProjectsFromView(db.getSession(), "FGHI", "EFGH")).containsOnly("JKLM");
+ assertThat(underTest.selectProjectsFromView(db.getSession(), "IJKL", "IJKL")).isEmpty();
+ assertThat(underTest.selectProjectsFromView(db.getSession(), "Unknown", "Unknown")).isEmpty();
}
@Test
public void select_provisioned_projects() {
db.prepareDbUnit(getClass(), "select_provisioned_projects.xml");
- List<ComponentDto> result = sut.selectProvisionedProjects(db.getSession(), 0, 10, null);
+ List<ComponentDto> result = underTest.selectProvisionedProjects(db.getSession(), 0, 10, null);
ComponentDto project = result.get(0);
assertThat(result).hasSize(1);
@@ -474,7 +474,7 @@ public class ComponentDaoTest {
public void count_provisioned_projects() {
db.prepareDbUnit(getClass(), "select_provisioned_projects.xml");
- int numberOfProjects = sut.countProvisionedProjects(db.getSession(), null);
+ int numberOfProjects = underTest.countProvisionedProjects(db.getSession(), null);
assertThat(numberOfProjects).isEqualTo(1);
}
@@ -483,11 +483,11 @@ public class ComponentDaoTest {
public void select_ghost_projects() {
db.prepareDbUnit(getClass(), "select_ghost_projects.xml");
- List<ComponentDto> result = sut.selectGhostProjects(db.getSession(), 0, 10, null);
+ List<ComponentDto> result = underTest.selectGhostProjects(db.getSession(), 0, 10, null);
assertThat(result).hasSize(1);
assertThat(result.get(0).key()).isEqualTo("org.ghost.project");
- assertThat(sut.countGhostProjects(db.getSession(), null)).isEqualTo(1);
+ assertThat(underTest.countGhostProjects(db.getSession(), null)).isEqualTo(1);
}
@Test
@@ -515,7 +515,7 @@ public class ComponentDaoTest {
.setCreatedAt(DateUtils.parseDate("2014-06-18"))
.setAuthorizationUpdatedAt(123456789L);
- sut.insert(db.getSession(), componentDto);
+ underTest.insert(db.getSession(), componentDto);
db.getSession().commit();
assertThat(componentDto.getId()).isNotNull();
@@ -544,7 +544,7 @@ public class ComponentDaoTest {
.setCreatedAt(DateUtils.parseDate("2014-06-18"))
.setAuthorizationUpdatedAt(123456789L);
- sut.insert(db.getSession(), componentDto);
+ underTest.insert(db.getSession(), componentDto);
db.getSession().commit();
assertThat(componentDto.getId()).isNotNull();
@@ -574,7 +574,7 @@ public class ComponentDaoTest {
.setEnabled(false)
.setAuthorizationUpdatedAt(12345678910L);
- sut.update(db.getSession(), componentDto);
+ underTest.update(db.getSession(), componentDto);
db.getSession().commit();
db.assertDbUnit(getClass(), "update-result.xml", "projects");
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java
index d2a7f81cc30..e9737aada6f 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java
@@ -47,13 +47,13 @@ public class ResourceDaoTest {
@Rule
public DbTester dbTester = DbTester.create(system);
- ResourceDao sut = dbTester.getDbClient().resourceDao();
+ ResourceDao underTest = dbTester.getDbClient().resourceDao();
@Test
public void get_resource_by_uuid() {
dbTester.prepareDbUnit(getClass(), "fixture.xml");
- ResourceDto resource = sut.getResource("ABCD");
+ ResourceDto resource = underTest.getResource("ABCD");
assertThat(resource.getUuid()).isEqualTo("ABCD");
assertThat(resource.getProjectUuid()).isEqualTo("ABCD");
@@ -74,19 +74,19 @@ public class ResourceDaoTest {
ResourceQuery query = ResourceQuery.create().setKey("org.struts:struts-core");
- assertThat(sut.getResource(query).getKey()).isEqualTo("org.struts:struts-core");
+ assertThat(underTest.getResource(query).getKey()).isEqualTo("org.struts:struts-core");
}
@Test
public void find_root_project_by_component_key() {
dbTester.prepareDbUnit(getClass(), "fixture.xml");
- assertThat(sut.getRootProjectByComponentKey("org.struts:struts-core:src/org/struts/RequestContext.java").getKey()).isEqualTo("org.struts:struts");
- assertThat(sut.getRootProjectByComponentKey("org.struts:struts-core:src/org/struts").getKey()).isEqualTo("org.struts:struts");
- assertThat(sut.getRootProjectByComponentKey("org.struts:struts-core").getKey()).isEqualTo("org.struts:struts");
- assertThat(sut.getRootProjectByComponentKey("org.struts:struts").getKey()).isEqualTo("org.struts:struts");
+ assertThat(underTest.getRootProjectByComponentKey("org.struts:struts-core:src/org/struts/RequestContext.java").getKey()).isEqualTo("org.struts:struts");
+ assertThat(underTest.getRootProjectByComponentKey("org.struts:struts-core:src/org/struts").getKey()).isEqualTo("org.struts:struts");
+ assertThat(underTest.getRootProjectByComponentKey("org.struts:struts-core").getKey()).isEqualTo("org.struts:struts");
+ assertThat(underTest.getRootProjectByComponentKey("org.struts:struts").getKey()).isEqualTo("org.struts:struts");
- assertThat(sut.getRootProjectByComponentKey("unknown")).isNull();
+ assertThat(underTest.getRootProjectByComponentKey("unknown")).isNull();
}
@Test
@@ -102,8 +102,8 @@ public class ResourceDaoTest {
.setDeprecatedKey("org.struts:struts:org.struts.Filter").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE)
.setLanguage("java").setName("Filter").setLongName("org.struts.Filter");
- sut.insertUsingExistingSession(file1, dbTester.getSession());
- sut.insertUsingExistingSession(file2, dbTester.getSession());
+ underTest.insertUsingExistingSession(file1, dbTester.getSession());
+ underTest.insertUsingExistingSession(file2, dbTester.getSession());
dbTester.getSession().rollback();
@@ -114,59 +114,59 @@ public class ResourceDaoTest {
public void should_find_component_by_key() {
dbTester.prepareDbUnit(getClass(), "fixture.xml");
- assertThat(sut.findByKey("org.struts:struts")).isNotNull();
- Component component = sut.findByKey("org.struts:struts-core:src/org/struts/RequestContext.java");
+ assertThat(underTest.findByKey("org.struts:struts")).isNotNull();
+ Component component = underTest.findByKey("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(component).isNotNull();
assertThat(component.path()).isEqualTo("src/org/struts/RequestContext.java");
- assertThat(sut.findByKey("unknown")).isNull();
+ assertThat(underTest.findByKey("unknown")).isNull();
}
@Test
public void should_select_projects_by_qualifiers() {
dbTester.prepareDbUnit(getClass(), "fixture-including-ghost-projects-and-technical-project.xml");
- List<Component> components = sut.selectProjectsByQualifiers(newArrayList("TRK"));
+ List<Component> components = underTest.selectProjectsByQualifiers(newArrayList("TRK"));
assertThat(components).hasSize(1);
assertThat(components.get(0).key()).isEqualTo("org.struts:struts");
assertThat(((ComponentDto) components.get(0)).getId()).isEqualTo(1L);
- assertThat(sut.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("unknown"))).isEmpty();
- assertThat(sut.selectProjectsIncludingNotCompletedOnesByQualifiers(Collections.<String>emptyList())).isEmpty();
+ assertThat(underTest.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("unknown"))).isEmpty();
+ assertThat(underTest.selectProjectsIncludingNotCompletedOnesByQualifiers(Collections.<String>emptyList())).isEmpty();
}
@Test
public void should_select_projects_including_not_finished_by_qualifiers() {
dbTester.prepareDbUnit(getClass(), "fixture-including-ghost-projects-and-technical-project.xml");
- List<Component> components = sut.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("TRK"));
+ List<Component> components = underTest.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("TRK"));
assertThat(getKeys(components)).containsOnly("org.struts:struts", "org.apache.shindig", "org.sample:sample");
- assertThat(sut.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("unknown"))).isEmpty();
- assertThat(sut.selectProjectsIncludingNotCompletedOnesByQualifiers(Collections.<String>emptyList())).isEmpty();
+ assertThat(underTest.selectProjectsIncludingNotCompletedOnesByQualifiers(newArrayList("unknown"))).isEmpty();
+ assertThat(underTest.selectProjectsIncludingNotCompletedOnesByQualifiers(Collections.<String>emptyList())).isEmpty();
}
@Test
public void should_select_ghosts_projects_by_qualifiers() {
dbTester.prepareDbUnit(getClass(), "fixture-including-ghost-projects-and-technical-project.xml");
- List<Component> components = sut.selectGhostsProjects(newArrayList("TRK"));
+ List<Component> components = underTest.selectGhostsProjects(newArrayList("TRK"));
assertThat(components).hasSize(1);
assertThat(getKeys(components)).containsOnly("org.apache.shindig");
- assertThat(sut.selectGhostsProjects(newArrayList("unknown"))).isEmpty();
- assertThat(sut.selectGhostsProjects(Collections.<String>emptyList())).isEmpty();
+ assertThat(underTest.selectGhostsProjects(newArrayList("unknown"))).isEmpty();
+ assertThat(underTest.selectGhostsProjects(Collections.<String>emptyList())).isEmpty();
}
@Test
public void should_select_provisioned_projects_by_qualifiers() {
dbTester.prepareDbUnit(getClass(), "fixture-including-ghost-projects-and-technical-project.xml");
- List<ResourceDto> components = sut.selectProvisionedProjects(newArrayList("TRK"));
+ List<ResourceDto> components = underTest.selectProvisionedProjects(newArrayList("TRK"));
assertThat(components).hasSize(1);
assertThat(components.get(0).getKey()).isEqualTo("org.sample:sample");
- assertThat(sut.selectProvisionedProjects(newArrayList("unknown"))).isEmpty();
- assertThat(sut.selectProvisionedProjects(Collections.<String>emptyList())).isEmpty();
+ assertThat(underTest.selectProvisionedProjects(newArrayList("unknown"))).isEmpty();
+ assertThat(underTest.selectProvisionedProjects(Collections.<String>emptyList())).isEmpty();
}
@Test
@@ -174,7 +174,7 @@ public class ResourceDaoTest {
dbTester.prepareDbUnit(getClass(), "update_authorization_date.xml");
when(system.now()).thenReturn(987654321L);
- sut.updateAuthorizationDate(1L, dbTester.getSession());
+ underTest.updateAuthorizationDate(1L, dbTester.getSession());
dbTester.getSession().commit();
dbTester.assertDbUnit(getClass(), "update_authorization_date-result.xml", "projects");
diff --git a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
index e3978c2083a..f1afab1e9aa 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
@@ -41,13 +41,13 @@ public class SnapshotDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- SnapshotDao sut = db.getDbClient().snapshotDao();
+ SnapshotDao underTest = db.getDbClient().snapshotDao();
@Test
public void get_by_key() {
db.prepareDbUnit(getClass(), "shared.xml");
- SnapshotDto result = sut.selectNullableById(db.getSession(), 3L);
+ SnapshotDto result = underTest.selectNullableById(db.getSession(), 3L);
assertThat(result).isNotNull();
assertThat(result.getId()).isEqualTo(3L);
assertThat(result.getComponentId()).isEqualTo(3L);
@@ -82,12 +82,12 @@ public class SnapshotDaoTest {
assertThat(result.getCreatedAt()).isEqualTo(1228172400000L);
assertThat(result.getBuildDate()).isEqualTo(1317247200000L);
- assertThat(sut.selectNullableById(db.getSession(), 999L)).isNull();
+ assertThat(underTest.selectNullableById(db.getSession(), 999L)).isNull();
}
@Test
public void lastSnapshot_returns_null_when_no_last_snapshot() {
- SnapshotDto snapshot = sut.selectLastSnapshotByComponentId(db.getSession(), 123L);
+ SnapshotDto snapshot = underTest.selectLastSnapshotByComponentId(db.getSession(), 123L);
assertThat(snapshot).isNull();
}
@@ -96,7 +96,7 @@ public class SnapshotDaoTest {
public void lastSnapshot_from_one_resource() {
db.prepareDbUnit(getClass(), "snapshots.xml");
- SnapshotDto snapshot = sut.selectLastSnapshotByComponentId(db.getSession(), 2L);
+ SnapshotDto snapshot = underTest.selectLastSnapshotByComponentId(db.getSession(), 2L);
assertThat(snapshot).isNotNull();
assertThat(snapshot.getId()).isEqualTo(4L);
@@ -106,7 +106,7 @@ public class SnapshotDaoTest {
public void lastSnapshot_from_one_resource_without_last_is_null() {
db.prepareDbUnit(getClass(), "snapshots.xml");
- SnapshotDto snapshot = sut.selectLastSnapshotByComponentId(db.getSession(), 5L);
+ SnapshotDto snapshot = underTest.selectLastSnapshotByComponentId(db.getSession(), 5L);
assertThat(snapshot).isNull();
}
@@ -115,7 +115,7 @@ public class SnapshotDaoTest {
public void snapshot_and_child_retrieved() {
db.prepareDbUnit(getClass(), "snapshots.xml");
- List<SnapshotDto> snapshots = sut.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L);
+ List<SnapshotDto> snapshots = underTest.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L);
assertThat(snapshots).isNotEmpty();
assertThat(snapshots).extracting("id").containsOnly(1L, 6L);
@@ -125,7 +125,7 @@ public class SnapshotDaoTest {
public void select_snapshots_by_component_id() {
db.prepareDbUnit(getClass(), "snapshots.xml");
- List<SnapshotDto> snapshots = sut.selectSnapshotsByComponentId(db.getSession(), 1L);
+ List<SnapshotDto> snapshots = underTest.selectSnapshotsByComponentId(db.getSession(), 1L);
assertThat(snapshots).hasSize(3);
}
@@ -134,37 +134,37 @@ public class SnapshotDaoTest {
public void select_snapshots_by_query() {
db.prepareDbUnit(getClass(), "select_snapshots_by_query.xml");
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery())).hasSize(6);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery())).hasSize(6);
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L))).hasSize(3);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L))).hasSize(3);
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setVersion("2.2-SNAPSHOT"))).extracting("id").containsOnly(3L);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setVersion("2.2-SNAPSHOT"))).extracting("id").containsOnly(3L);
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setIsLast(true))).extracting("id").containsOnly(1L);
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setIsLast(false))).extracting("id").containsOnly(2L, 3L);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setIsLast(true))).extracting("id").containsOnly(1L);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setIsLast(false))).extracting("id").containsOnly(2L, 3L);
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setCreatedAfter(1228172400002L))).extracting("id").containsOnly(2L, 3L);
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setCreatedBefore(1228172400002L))).extracting("id").containsOnly(1L);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setCreatedAfter(1228172400002L))).extracting("id").containsOnly(2L, 3L);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setCreatedBefore(1228172400002L))).extracting("id").containsOnly(1L);
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(2L).setStatus("P"))).hasSize(1);
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(2L).setStatus("U"))).hasSize(1);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(2L).setStatus("P"))).hasSize(1);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(2L).setStatus("U"))).hasSize(1);
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, ASC)).get(0).getId()).isEqualTo(1L);
- assertThat(sut.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, DESC)).get(0).getId()).isEqualTo(3L);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, ASC)).get(0).getId()).isEqualTo(1L);
+ assertThat(underTest.selectSnapshotsByQuery(db.getSession(), new SnapshotQuery().setComponentId(1L).setSort(BY_DATE, DESC)).get(0).getId()).isEqualTo(3L);
}
@Test
public void select_previous_version_snapshots() {
db.prepareDbUnit(getClass(), "select_previous_version_snapshots.xml");
- List<SnapshotDto> snapshots = sut.selectPreviousVersionSnapshots(db.getSession(), 1L, "1.2-SNAPSHOT");
+ List<SnapshotDto> snapshots = underTest.selectPreviousVersionSnapshots(db.getSession(), 1L, "1.2-SNAPSHOT");
assertThat(snapshots).hasSize(2);
SnapshotDto firstSnapshot = snapshots.get(0);
assertThat(firstSnapshot.getVersion()).isEqualTo("1.1");
// All snapshots are returned on an unknown version
- assertThat(sut.selectPreviousVersionSnapshots(db.getSession(), 1L, "UNKNOWN")).hasSize(3);
+ assertThat(underTest.selectPreviousVersionSnapshots(db.getSession(), 1L, "UNKNOWN")).hasSize(3);
}
@Test
@@ -173,7 +173,7 @@ public class SnapshotDaoTest {
SnapshotDto dto = defaultSnapshot().setCreatedAt(1403042400000L);
- sut.insert(db.getSession(), dto);
+ underTest.insert(db.getSession(), dto);
db.getSession().commit();
assertThat(dto.getId()).isNotNull();
@@ -184,7 +184,7 @@ public class SnapshotDaoTest {
public void insert_snapshots() {
db.prepareDbUnit(getClass(), "empty.xml");
- sut.insert(db.getSession(),
+ underTest.insert(db.getSession(),
new SnapshotDto().setComponentId(1L).setLast(false),
new SnapshotDto().setComponentId(2L).setLast(false));
db.getSession().commit();
@@ -197,10 +197,10 @@ public class SnapshotDaoTest {
db.prepareDbUnit(getClass(), "snapshots.xml");
SnapshotDto snapshot = defaultSnapshot().setId(1L);
- sut.updateSnapshotAndChildrenLastFlagAndStatus(db.getSession(), snapshot, false, SnapshotDto.STATUS_PROCESSED);
+ underTest.updateSnapshotAndChildrenLastFlagAndStatus(db.getSession(), snapshot, false, SnapshotDto.STATUS_PROCESSED);
db.getSession().commit();
- List<SnapshotDto> snapshots = sut.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L);
+ List<SnapshotDto> snapshots = underTest.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L);
assertThat(snapshots).hasSize(2);
assertThat(snapshots).extracting("id").containsOnly(1L, 6L);
assertThat(snapshots).extracting("last").containsOnly(false);
@@ -212,10 +212,10 @@ public class SnapshotDaoTest {
db.prepareDbUnit(getClass(), "snapshots.xml");
SnapshotDto snapshot = defaultSnapshot().setId(1L);
- sut.updateSnapshotAndChildrenLastFlag(db.getSession(), snapshot, false);
+ underTest.updateSnapshotAndChildrenLastFlag(db.getSession(), snapshot, false);
db.getSession().commit();
- List<SnapshotDto> snapshots = sut.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L);
+ List<SnapshotDto> snapshots = underTest.selectSnapshotAndChildrenOfProjectScope(db.getSession(), 1L);
assertThat(snapshots).hasSize(2);
assertThat(snapshots).extracting("id").containsOnly(1L, 6L);
assertThat(snapshots).extracting("last").containsOnly(false);
diff --git a/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java b/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java
index c86e7304724..6a1e740a7f3 100644
--- a/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/compute/AnalysisReportDaoTest.java
@@ -48,7 +48,7 @@ public class AnalysisReportDaoTest {
@Rule
public DbTester db = DbTester.create(system2);
- AnalysisReportDao sut = db.getDbClient().analysisReportDao();
+ AnalysisReportDao underTest = db.getDbClient().analysisReportDao();
@Test
public void insert_multiple_reports() {
@@ -58,8 +58,8 @@ public class AnalysisReportDaoTest {
AnalysisReportDto report1 = new AnalysisReportDto().setProjectKey("ProjectKey1").setProjectName("Project 1").setUuid("UUID_1").setStatus(PENDING);
AnalysisReportDto report2 = new AnalysisReportDto().setProjectKey("ProjectKey2").setProjectName("Project 2").setUuid("UUID_2").setStatus(PENDING);
- sut.insert(db.getSession(), report1);
- sut.insert(db.getSession(), report2);
+ underTest.insert(db.getSession(), report1);
+ underTest.insert(db.getSession(), report2);
db.getSession().commit();
db.assertDbUnit(getClass(), "insert-result.xml", "analysis_reports");
@@ -69,7 +69,7 @@ public class AnalysisReportDaoTest {
public void resetAllToPendingStatus() {
db.prepareDbUnit(getClass(), "update-all-to-status-pending.xml");
- sut.resetAllToPendingStatus(db.getSession());
+ underTest.resetAllToPendingStatus(db.getSession());
db.getSession().commit();
db.assertDbUnit(getClass(), "update-all-to-status-pending-result.xml", "analysis_reports");
@@ -79,7 +79,7 @@ public class AnalysisReportDaoTest {
public void truncate() {
db.prepareDbUnit(getClass(), "any-analysis-reports.xml");
- sut.truncate(db.getSession());
+ underTest.truncate(db.getSession());
db.getSession().commit();
db.assertDbUnit(getClass(), "truncate-result.xml", "analysis_reports");
@@ -90,7 +90,7 @@ public class AnalysisReportDaoTest {
db.prepareDbUnit(getClass(), "select.xml");
final String projectKey = "123456789-987654321";
- List<AnalysisReportDto> reports = sut.selectByProjectKey(db.getSession(), projectKey);
+ List<AnalysisReportDto> reports = underTest.selectByProjectKey(db.getSession(), projectKey);
AnalysisReportDto report = reports.get(0);
assertThat(reports).hasSize(1);
@@ -105,7 +105,7 @@ public class AnalysisReportDaoTest {
db.prepareDbUnit(getClass(), "select.xml");
final String projectKey = "987654321-123456789";
- List<AnalysisReportDto> reports = sut.selectByProjectKey(db.getSession(), projectKey);
+ List<AnalysisReportDto> reports = underTest.selectByProjectKey(db.getSession(), projectKey);
assertThat(reports).hasSize(2);
}
@@ -114,7 +114,7 @@ public class AnalysisReportDaoTest {
public void pop_oldest_pending() {
db.prepareDbUnit(getClass(), "pop_oldest_pending.xml");
- AnalysisReportDto nextAvailableReport = sut.pop(db.getSession());
+ AnalysisReportDto nextAvailableReport = underTest.pop(db.getSession());
assertThat(nextAvailableReport.getId()).isEqualTo(3);
assertThat(nextAvailableReport.getProjectKey()).isEqualTo("P2");
@@ -124,7 +124,7 @@ public class AnalysisReportDaoTest {
public void pop_null_if_no_pending_reports() {
db.prepareDbUnit(getClass(), "pop_null_if_no_pending_reports.xml");
- AnalysisReportDto nextAvailableReport = sut.pop(db.getSession());
+ AnalysisReportDto nextAvailableReport = underTest.pop(db.getSession());
assertThat(nextAvailableReport).isNull();
}
@@ -133,7 +133,7 @@ public class AnalysisReportDaoTest {
public void getById_maps_all_the_fields_except_the_data() {
db.prepareDbUnit(getClass(), "one_analysis_report.xml");
- AnalysisReportDto report = sut.selectById(db.getSession(), 1L);
+ AnalysisReportDto report = underTest.selectById(db.getSession(), 1L);
assertThat(report.getProjectKey()).isEqualTo(DEFAULT_PROJECT_KEY);
assertThat(report.getCreatedAt()).isEqualTo(1_500_000_000_001L);
@@ -147,7 +147,7 @@ public class AnalysisReportDaoTest {
public void getById_returns_null_when_id_not_found() {
db.prepareDbUnit(getClass(), "select.xml");
- AnalysisReportDto report = sut.selectById(db.getSession(), 4L);
+ AnalysisReportDto report = underTest.selectById(db.getSession(), 4L);
assertThat(report).isNull();
}
@@ -156,7 +156,7 @@ public class AnalysisReportDaoTest {
public void delete_one_analysis_report() {
db.prepareDbUnit(getClass(), "one_analysis_report.xml");
- sut.delete(db.getSession(), 1);
+ underTest.delete(db.getSession(), 1);
db.getSession().commit();
db.assertDbUnit(getClass(), "truncate-result.xml", "analysis_reports");
@@ -166,7 +166,7 @@ public class AnalysisReportDaoTest {
public void findAll_one_analysis_report() {
db.prepareDbUnit(getClass(), "one_analysis_report.xml");
- List<AnalysisReportDto> reports = sut.selectAll(db.getSession());
+ List<AnalysisReportDto> reports = underTest.selectAll(db.getSession());
assertThat(reports).hasSize(1);
}
@@ -175,7 +175,7 @@ public class AnalysisReportDaoTest {
public void findAll_empty_table() {
db.prepareDbUnit(getClass(), "empty.xml");
- List<AnalysisReportDto> reports = sut.selectAll(db.getSession());
+ List<AnalysisReportDto> reports = underTest.selectAll(db.getSession());
assertThat(reports).isEmpty();
}
@@ -184,7 +184,7 @@ public class AnalysisReportDaoTest {
public void findAll_three_analysis_reports() {
db.prepareDbUnit(getClass(), "three_analysis_reports.xml");
- List<AnalysisReportDto> reports = sut.selectAll(db.getSession());
+ List<AnalysisReportDto> reports = underTest.selectAll(db.getSession());
assertThat(reports).hasSize(3);
}
diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
index 8f7bc6bce9e..196f1cba010 100644
--- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
@@ -42,13 +42,13 @@ public class MeasureDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- MeasureDao sut = db.getDbClient().measureDao();
+ MeasureDao underTest = db.getDbClient().measureDao();
@Test
public void get_value_by_key() {
db.prepareDbUnit(getClass(), "shared.xml");
- MeasureDto result = sut.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc");
+ MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc");
assertThat(result.getId()).isEqualTo(22);
assertThat(result.getValue()).isEqualTo(10d);
assertThat(result.getData()).isNull();
@@ -66,7 +66,7 @@ public class MeasureDaoTest {
public void get_data_by_key() {
db.prepareDbUnit(getClass(), "shared.xml");
- MeasureDto result = sut.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "authors_by_line");
+ MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "authors_by_line");
assertThat(result.getId()).isEqualTo(20);
assertThat(result.getData()).isEqualTo("0123456789012345678901234567890123456789");
}
@@ -75,7 +75,7 @@ public class MeasureDaoTest {
public void get_text_value_by_key() {
db.prepareDbUnit(getClass(), "shared.xml");
- MeasureDto result = sut.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "coverage_line_hits_data");
+ MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "coverage_line_hits_data");
assertThat(result.getId()).isEqualTo(21);
assertThat(result.getData()).isEqualTo("36=1;37=1;38=1;39=1;43=1;48=1;53=1");
}
@@ -84,11 +84,11 @@ public class MeasureDaoTest {
public void find_by_component_key_and_metrics() {
db.prepareDbUnit(getClass(), "shared.xml");
- List<MeasureDto> results = sut.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java",
+ List<MeasureDto> results = underTest.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java",
newArrayList("ncloc", "authors_by_line"));
assertThat(results).hasSize(2);
- results = sut.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc"));
+ results = underTest.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc"));
assertThat(results).hasSize(1);
MeasureDto result = results.get(0);
@@ -107,7 +107,7 @@ public class MeasureDaoTest {
public void find_by_component_key_and_metric() {
db.prepareDbUnit(getClass(), "shared.xml");
- MeasureDto result = sut.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc");
+ MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc");
assertThat(result.getId()).isEqualTo(22);
assertThat(result.getValue()).isEqualTo(10d);
assertThat(result.getMetricKey()).isEqualTo("ncloc");
@@ -118,22 +118,22 @@ public class MeasureDaoTest {
assertThat(result.getVariation(4)).isEqualTo(4d);
assertThat(result.getVariation(5)).isEqualTo(-5d);
- assertThat(sut.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isNull();
+ assertThat(underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isNull();
}
@Test
public void exists_by_key() {
db.prepareDbUnit(getClass(), "shared.xml");
- assertThat(sut.existsByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc")).isTrue();
- assertThat(sut.existsByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isFalse();
+ assertThat(underTest.existsByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc")).isTrue();
+ assertThat(underTest.existsByKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isFalse();
}
@Test
public void select_past_measures_by_component_uuid_and_root_snapshot_id_and_metric_keys() {
db.prepareDbUnit(getClass(), "past_measures.xml");
- List<PastMeasureDto> fileMeasures = sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 1000L, ImmutableSet.of(1, 2));
+ List<PastMeasureDto> fileMeasures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 1000L, ImmutableSet.of(1, 2));
assertThat(fileMeasures).hasSize(2);
PastMeasureDto fileMeasure1 = fileMeasures.get(0);
@@ -147,7 +147,7 @@ public class MeasureDaoTest {
assertThat(fileMeasure2.getValue()).isEqualTo(60d);
assertThat(fileMeasure2.getMetricId()).isEqualTo(2);
- List<PastMeasureDto> projectMeasures = sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1, 2));
+ List<PastMeasureDto> projectMeasures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1, 2));
assertThat(projectMeasures).hasSize(2);
PastMeasureDto projectMeasure1 = projectMeasures.get(0);
@@ -158,9 +158,9 @@ public class MeasureDaoTest {
assertThat(projectMeasure2.getValue()).isEqualTo(80d);
assertThat(projectMeasure2.getMetricId()).isEqualTo(2);
- assertThat(sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "UNKNOWN", 1000L, ImmutableSet.of(1, 2))).isEmpty();
- assertThat(sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 987654L, ImmutableSet.of(1, 2))).isEmpty();
- assertThat(sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 1000L, ImmutableSet.of(123, 456))).isEmpty();
+ assertThat(underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "UNKNOWN", 1000L, ImmutableSet.of(1, 2))).isEmpty();
+ assertThat(underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 987654L, ImmutableSet.of(1, 2))).isEmpty();
+ assertThat(underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "CDEF", 1000L, ImmutableSet.of(123, 456))).isEmpty();
}
@Test
@@ -168,7 +168,7 @@ public class MeasureDaoTest {
db.prepareDbUnit(getClass(), "past_measures_with_rule_id.xml");
db.getSession().commit();
- List<PastMeasureDto> measures = sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1));
+ List<PastMeasureDto> measures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1));
assertThat(measures).hasSize(3);
Map<Long, PastMeasureDto> pastMeasuresById = pastMeasuresById(measures);
@@ -199,7 +199,7 @@ public class MeasureDaoTest {
public void select_past_measures_on_characteristic_by_component_uuid_and_root_snapshot_id_and_metric_keys() {
db.prepareDbUnit(getClass(), "past_measures_with_characteristic_id.xml");
- List<PastMeasureDto> measures = sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1));
+ List<PastMeasureDto> measures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1));
assertThat(measures).hasSize(3);
Map<Long, PastMeasureDto> pastMeasuresById = pastMeasuresById(measures);
@@ -230,7 +230,7 @@ public class MeasureDaoTest {
public void select_past_measures_on_person_by_component_uuid_and_root_snapshot_id_and_metric_keys() {
db.prepareDbUnit(getClass(), "past_measures_with_person_id.xml");
- List<PastMeasureDto> measures = sut.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1));
+ List<PastMeasureDto> measures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(db.getSession(), "ABCD", 1000L, ImmutableSet.of(1));
assertThat(measures).hasSize(3);
Map<Long, PastMeasureDto> pastMeasuresById = pastMeasuresById(measures);
@@ -261,7 +261,7 @@ public class MeasureDaoTest {
public void insert() {
db.prepareDbUnit(getClass(), "empty.xml");
- sut.insert(db.getSession(), new MeasureDto()
+ underTest.insert(db.getSession(), new MeasureDto()
.setSnapshotId(2L)
.setMetricId(3)
.setCharacteristicId(4)
@@ -288,7 +288,7 @@ public class MeasureDaoTest {
public void insert_measures() {
db.prepareDbUnit(getClass(), "empty.xml");
- sut.insert(db.getSession(), new MeasureDto()
+ underTest.insert(db.getSession(), new MeasureDto()
.setSnapshotId(2L)
.setMetricId(3)
.setComponentId(6L)
diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java
index 058b0007c6c..fb80a71d966 100644
--- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java
@@ -27,11 +27,11 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MeasureDtoTest {
- MeasureDto sut = new MeasureDto();
+ MeasureDto underTest = new MeasureDto();
@Test
public void test_getter_and_setter() throws Exception {
- sut
+ underTest
.setComponentKey("component")
.setMetricKey("metric")
.setId(10L)
@@ -43,33 +43,33 @@ public class MeasureDtoTest {
.setVariation(4, 4d)
.setVariation(5, 5d);
- assertThat(sut.getId()).isEqualTo(10);
- assertThat(sut.getValue()).isEqualTo(2d);
- assertThat(sut.getData()).isNotNull();
- assertThat(sut.getVariation(1)).isEqualTo(1d);
- assertThat(sut.getVariation(2)).isEqualTo(2d);
- assertThat(sut.getVariation(3)).isEqualTo(3d);
- assertThat(sut.getVariation(4)).isEqualTo(4d);
- assertThat(sut.getVariation(5)).isEqualTo(5d);
+ assertThat(underTest.getId()).isEqualTo(10);
+ assertThat(underTest.getValue()).isEqualTo(2d);
+ assertThat(underTest.getData()).isNotNull();
+ assertThat(underTest.getVariation(1)).isEqualTo(1d);
+ assertThat(underTest.getVariation(2)).isEqualTo(2d);
+ assertThat(underTest.getVariation(3)).isEqualTo(3d);
+ assertThat(underTest.getVariation(4)).isEqualTo(4d);
+ assertThat(underTest.getVariation(5)).isEqualTo(5d);
}
@Test
public void value_with_text_over_4000_characters() {
- assertThat(sut.setData(Strings.repeat("1", 4001)).getData()).isNotNull();
+ assertThat(underTest.setData(Strings.repeat("1", 4001)).getData()).isNotNull();
}
@Test
public void text_value_under_4000_characters() {
- assertThat(sut.setData("text value").getData()).isEqualTo("text value");
+ assertThat(underTest.setData("text value").getData()).isEqualTo("text value");
}
@Test(expected = IndexOutOfBoundsException.class)
public void fail_to_set_out_of_bounds_variation() {
- sut.setVariation(6, 1d);
+ underTest.setVariation(6, 1d);
}
@Test(expected = IndexOutOfBoundsException.class)
public void fail_to_get_out_of_bounds_variation() {
- sut.getVariation(6);
+ underTest.getVariation(6);
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java
index 559b4779032..31307a148b4 100644
--- a/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java
@@ -43,13 +43,13 @@ public class CustomMeasureDaoTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- CustomMeasureDao sut;
+ CustomMeasureDao underTest;
DbSession session;
@Before
public void setUp() {
session = db.getSession();
- sut = new CustomMeasureDao();
+ underTest = new CustomMeasureDao();
db.truncateTables();
}
@@ -57,9 +57,9 @@ public class CustomMeasureDaoTest {
public void insert() {
CustomMeasureDto measure = newCustomMeasureDto();
- sut.insert(session, measure);
+ underTest.insert(session, measure);
- CustomMeasureDto result = sut.selectById(session, measure.getId());
+ CustomMeasureDto result = underTest.selectById(session, measure.getId());
assertThat(result.getId()).isEqualTo(measure.getId());
assertThat(result.getMetricId()).isEqualTo(measure.getMetricId());
assertThat(result.getComponentUuid()).isEqualTo(measure.getComponentUuid());
@@ -74,56 +74,56 @@ public class CustomMeasureDaoTest {
@Test
public void delete_by_metric_id() {
CustomMeasureDto measure = newCustomMeasureDto();
- sut.insert(session, measure);
- assertThat(sut.selectNullableById(session, measure.getId())).isNotNull();
+ underTest.insert(session, measure);
+ assertThat(underTest.selectNullableById(session, measure.getId())).isNotNull();
- sut.deleteByMetricIds(session, Arrays.asList(measure.getMetricId()));
+ underTest.deleteByMetricIds(session, Arrays.asList(measure.getMetricId()));
- assertThat(sut.selectNullableById(session, measure.getId())).isNull();
+ assertThat(underTest.selectNullableById(session, measure.getId())).isNull();
}
@Test
public void update() {
CustomMeasureDto measure = newCustomMeasureDto().setDescription("old-description");
- sut.insert(session, measure);
+ underTest.insert(session, measure);
measure.setDescription("new-description");
- sut.update(session, measure);
+ underTest.update(session, measure);
- assertThat(sut.selectNullableById(session, measure.getId()).getDescription()).isEqualTo("new-description");
+ assertThat(underTest.selectNullableById(session, measure.getId()).getDescription()).isEqualTo("new-description");
}
@Test
public void delete() {
CustomMeasureDto measure = newCustomMeasureDto();
- sut.insert(session, measure);
+ underTest.insert(session, measure);
- sut.delete(session, measure.getId());
- assertThat(sut.selectNullableById(session, measure.getId())).isNull();
+ underTest.delete(session, measure.getId());
+ assertThat(underTest.selectNullableById(session, measure.getId())).isNull();
}
@Test
public void select_by_component_uuid() {
- sut.insert(session, newCustomMeasureDto().setComponentUuid("u1"));
- sut.insert(session, newCustomMeasureDto().setComponentUuid("u1"));
- sut.insert(session, newCustomMeasureDto().setComponentUuid("u2"));
+ underTest.insert(session, newCustomMeasureDto().setComponentUuid("u1"));
+ underTest.insert(session, newCustomMeasureDto().setComponentUuid("u1"));
+ underTest.insert(session, newCustomMeasureDto().setComponentUuid("u2"));
session.commit();
- List<CustomMeasureDto> result = sut.selectByComponentUuid(session, "u1");
+ List<CustomMeasureDto> result = underTest.selectByComponentUuid(session, "u1");
assertThat(result).hasSize(2);
assertThat(result).extracting("componentUuid").containsOnly("u1");
- assertThat(sut.countByComponentUuid(session, "u1")).isEqualTo(2);
+ assertThat(underTest.countByComponentUuid(session, "u1")).isEqualTo(2);
}
@Test
public void select_by_component_uuid_with_options() {
- sut.insert(session, newCustomMeasureDto().setComponentUuid("u1"));
- sut.insert(session, newCustomMeasureDto().setComponentUuid("u1"));
- sut.insert(session, newCustomMeasureDto().setComponentUuid("u2"));
+ underTest.insert(session, newCustomMeasureDto().setComponentUuid("u1"));
+ underTest.insert(session, newCustomMeasureDto().setComponentUuid("u1"));
+ underTest.insert(session, newCustomMeasureDto().setComponentUuid("u2"));
session.commit();
- List<CustomMeasureDto> result = sut.selectByComponentUuid(session, "u1", 0, 100);
+ List<CustomMeasureDto> result = underTest.selectByComponentUuid(session, "u1", 0, 100);
assertThat(result).hasSize(2);
assertThat(result).extracting("componentUuid").containsOnly("u1");
@@ -131,20 +131,20 @@ public class CustomMeasureDaoTest {
@Test
public void select_by_metric_id() {
- sut.insert(session, newCustomMeasureDto().setMetricId(123));
- sut.insert(session, newCustomMeasureDto().setMetricId(123));
+ underTest.insert(session, newCustomMeasureDto().setMetricId(123));
+ underTest.insert(session, newCustomMeasureDto().setMetricId(123));
- List<CustomMeasureDto> result = sut.selectByMetricId(session, 123);
+ List<CustomMeasureDto> result = underTest.selectByMetricId(session, 123);
assertThat(result).hasSize(2);
}
@Test
public void count_by_component_uuid_and_metric_id() {
- sut.insert(session, newCustomMeasureDto().setMetricId(123).setComponentUuid("123"));
- sut.insert(session, newCustomMeasureDto().setMetricId(123).setComponentUuid("123"));
+ underTest.insert(session, newCustomMeasureDto().setMetricId(123).setComponentUuid("123"));
+ underTest.insert(session, newCustomMeasureDto().setMetricId(123).setComponentUuid("123"));
- int count = sut.countByComponentIdAndMetricId(session, "123", 123);
+ int count = underTest.countByComponentIdAndMetricId(session, "123", 123);
assertThat(count).isEqualTo(2);
}
@@ -153,7 +153,7 @@ public class CustomMeasureDaoTest {
public void select_by_id_fail_if_no_measure_found() {
expectedException.expect(IllegalArgumentException.class);
- sut.selectById(session, 42L);
+ underTest.selectById(session, 42L);
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
index b981084b439..84aaa26470a 100644
--- a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
@@ -40,33 +40,33 @@ public class PurgeDaoTest {
@Rule
public DbTester dbTester = DbTester.create(system2);
- PurgeDao sut = dbTester.getDbClient().purgeDao();
+ PurgeDao underTest = dbTester.getDbClient().purgeDao();
@Test
public void shouldDeleteAbortedBuilds() {
dbTester.prepareDbUnit(getClass(), "shouldDeleteAbortedBuilds.xml");
- sut.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler());
+ underTest.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler());
dbTester.assertDbUnit(getClass(), "shouldDeleteAbortedBuilds-result.xml", "snapshots");
}
@Test
public void should_purge_project() {
dbTester.prepareDbUnit(getClass(), "shouldPurgeProject.xml");
- sut.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler());
+ underTest.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler());
dbTester.assertDbUnit(getClass(), "shouldPurgeProject-result.xml", "projects", "snapshots");
}
@Test
public void delete_file_sources_of_disabled_resources() {
dbTester.prepareDbUnit(getClass(), "delete_file_sources_of_disabled_resources.xml");
- sut.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler());
+ underTest.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler());
dbTester.assertDbUnit(getClass(), "delete_file_sources_of_disabled_resources-result.xml", "file_sources");
}
@Test
public void shouldDeleteHistoricalDataOfDirectoriesAndFiles() {
dbTester.prepareDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml");
- sut.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[] {Scopes.DIRECTORY, Scopes.FILE}, 30), PurgeListener.EMPTY, new PurgeProfiler());
+ underTest.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[]{Scopes.DIRECTORY, Scopes.FILE}, 30), PurgeListener.EMPTY, new PurgeProfiler());
dbTester.assertDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml", "projects", "snapshots");
}
@@ -74,7 +74,7 @@ public class PurgeDaoTest {
public void disable_resources_without_last_snapshot() {
dbTester.prepareDbUnit(getClass(), "disable_resources_without_last_snapshot.xml");
when(system2.now()).thenReturn(1450000000000L);
- sut.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler());
+ underTest.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler());
dbTester.assertDbUnit(getClass(), "disable_resources_without_last_snapshot-result.xml", new String[] {"issue_close_date", "issue_update_date"}, "projects", "snapshots",
"issues");
}
@@ -82,14 +82,14 @@ public class PurgeDaoTest {
@Test
public void shouldDeleteSnapshots() {
dbTester.prepareDbUnit(getClass(), "shouldDeleteSnapshots.xml");
- sut.deleteSnapshots(PurgeSnapshotQuery.create().setIslast(false).setResourceId(1L), new PurgeProfiler());
+ underTest.deleteSnapshots(PurgeSnapshotQuery.create().setIslast(false).setResourceId(1L), new PurgeProfiler());
dbTester.assertDbUnit(getClass(), "shouldDeleteSnapshots-result.xml", "snapshots");
}
@Test
public void shouldSelectPurgeableSnapshots() {
dbTester.prepareDbUnit(getClass(), "shouldSelectPurgeableSnapshots.xml");
- List<PurgeableSnapshotDto> snapshots = sut.selectPurgeableSnapshots(1L);
+ List<PurgeableSnapshotDto> snapshots = underTest.selectPurgeableSnapshots(1L);
assertThat(snapshots).hasSize(3);
assertThat(getById(snapshots, 1L).isLast()).isTrue();
@@ -103,7 +103,7 @@ public class PurgeDaoTest {
@Test
public void should_delete_project_and_associated_data() {
dbTester.prepareDbUnit(getClass(), "shouldDeleteProject.xml");
- sut.deleteResourceTree(new IdUuidPair(1L, "A"), new PurgeProfiler());
+ underTest.deleteResourceTree(new IdUuidPair(1L, "A"), new PurgeProfiler());
assertThat(dbTester.countRowsOfTable("projects")).isZero();
assertThat(dbTester.countRowsOfTable("snapshots")).isZero();
assertThat(dbTester.countRowsOfTable("action_plans")).isZero();
@@ -115,14 +115,14 @@ public class PurgeDaoTest {
@Test
public void should_delete_old_closed_issues() {
dbTester.prepareDbUnit(getClass(), "should_delete_old_closed_issues.xml");
- sut.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler());
+ underTest.purge(newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler());
dbTester.assertDbUnit(getClass(), "should_delete_old_closed_issues-result.xml", "issues", "issue_changes");
}
@Test
public void should_delete_all_closed_issues() {
dbTester.prepareDbUnit(getClass(), "should_delete_all_closed_issues.xml");
- sut.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 0), PurgeListener.EMPTY, new PurgeProfiler());
+ underTest.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 0), PurgeListener.EMPTY, new PurgeProfiler());
dbTester.assertDbUnit(getClass(), "should_delete_all_closed_issues-result.xml", "issues", "issue_changes");
}
diff --git a/sonar-db/src/test/java/org/sonar/db/source/FileSourceDaoTest.java b/sonar-db/src/test/java/org/sonar/db/source/FileSourceDaoTest.java
index bf1f0d2f332..1ea318ab10c 100644
--- a/sonar-db/src/test/java/org/sonar/db/source/FileSourceDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/source/FileSourceDaoTest.java
@@ -40,13 +40,13 @@ public class FileSourceDaoTest {
@Rule
public DbTester dbTester = DbTester.create(System2.INSTANCE);
- FileSourceDao sut = dbTester.getDbClient().fileSourceDao();
+ FileSourceDao underTest = dbTester.getDbClient().fileSourceDao();
@Test
public void select() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
- FileSourceDto fileSourceDto = sut.selectSource("FILE1_UUID");
+ FileSourceDto fileSourceDto = underTest.selectSource("FILE1_UUID");
assertThat(fileSourceDto.getBinaryData()).isNotEmpty();
assertThat(fileSourceDto.getDataHash()).isEqualTo("hash");
@@ -62,7 +62,7 @@ public class FileSourceDaoTest {
dbTester.prepareDbUnit(getClass(), "shared.xml");
ReaderToStringFunction fn = new ReaderToStringFunction();
- sut.readLineHashesStream(dbTester.getSession(), "FILE1_UUID", fn);
+ underTest.readLineHashesStream(dbTester.getSession(), "FILE1_UUID", fn);
assertThat(fn.result).isEqualTo("ABC\\nDEF\\nGHI");
}
@@ -72,7 +72,7 @@ public class FileSourceDaoTest {
dbTester.prepareDbUnit(getClass(), "shared.xml");
ReaderToStringFunction fn = new ReaderToStringFunction();
- sut.readLineHashesStream(dbTester.getSession(), "unknown", fn);
+ underTest.readLineHashesStream(dbTester.getSession(), "unknown", fn);
assertThat(fn.result).isNull();
}
@@ -82,7 +82,7 @@ public class FileSourceDaoTest {
dbTester.prepareDbUnit(getClass(), "no_line_hashes_when_only_test_data.xml");
ReaderToStringFunction fn = new ReaderToStringFunction();
- sut.readLineHashesStream(dbTester.getSession(), "FILE1_UUID", fn);
+ underTest.readLineHashesStream(dbTester.getSession(), "FILE1_UUID", fn);
assertThat(fn.result).isNull();
}
@@ -91,7 +91,7 @@ public class FileSourceDaoTest {
public void insert() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
- sut.insert(new FileSourceDto()
+ underTest.insert(new FileSourceDto()
.setProjectUuid("PRJ_UUID")
.setFileUuid("FILE2_UUID")
.setBinaryData("FILE2_BINARY_DATA".getBytes())
@@ -110,7 +110,7 @@ public class FileSourceDaoTest {
public void update() {
dbTester.prepareDbUnit(getClass(), "shared.xml");
- sut.update(new FileSourceDto()
+ underTest.update(new FileSourceDto()
.setId(101L)
.setProjectUuid("PRJ_UUID")
.setFileUuid("FILE1_UUID")
@@ -129,7 +129,7 @@ public class FileSourceDaoTest {
public void update_date_when_updated_date_is_zero() {
dbTester.prepareDbUnit(getClass(), "update_date_when_updated_date_is_zero.xml");
- sut.updateDateWhenUpdatedDateIsZero(dbTester.getSession(), "ABCD", 1500000000002L);
+ underTest.updateDateWhenUpdatedDateIsZero(dbTester.getSession(), "ABCD", 1500000000002L);
dbTester.getSession().commit();
dbTester.assertDbUnitTable(getClass(), "update_date_when_updated_date_is_zero-result.xml", "file_sources",
diff --git a/sonar-db/src/test/java/org/sonar/db/source/FileSourceDtoTest.java b/sonar-db/src/test/java/org/sonar/db/source/FileSourceDtoTest.java
index 624dd4262cb..34d78e12779 100644
--- a/sonar-db/src/test/java/org/sonar/db/source/FileSourceDtoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/source/FileSourceDtoTest.java
@@ -40,10 +40,9 @@ public class FileSourceDtoTest {
.build()
);
- FileSourceDto sut = new FileSourceDto()
- .setTestData(tests);
+ FileSourceDto underTest = new FileSourceDto().setTestData(tests);
- assertThat(sut.getTestData()).hasSize(2);
- assertThat(sut.getTestData().get(0).getName()).isEqualTo("name#1");
+ assertThat(underTest.getTestData()).hasSize(2);
+ assertThat(underTest.getTestData().get(0).getName()).isEqualTo("name#1");
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggerTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggerTest.java
index 7edba887086..7e4d74c684c 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggerTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggerTest.java
@@ -30,7 +30,7 @@ import static org.mockito.Mockito.*;
public class ConsoleLoggerTest {
PrintStream stream = mock(PrintStream.class);
- ConsoleLogger sut = new ConsoleLogger(stream);
+ ConsoleLogger underTest = new ConsoleLogger(stream);
@Rule
public LogTester tester = new LogTester();
@@ -38,74 +38,74 @@ public class ConsoleLoggerTest {
@Test
public void debug_enabled() {
tester.setLevel(LoggerLevel.DEBUG);
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isFalse();
- sut.debug("message");
- sut.debug("message {}", "foo");
- sut.debug("message {} {}", "foo", "bar");
- sut.debug("message {} {} {}", "foo", "bar", "baz");
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isFalse();
+ underTest.debug("message");
+ underTest.debug("message {}", "foo");
+ underTest.debug("message {} {}", "foo", "bar");
+ underTest.debug("message {} {} {}", "foo", "bar", "baz");
verify(stream, times(4)).println(anyString());
}
@Test
public void debug_disabled() {
tester.setLevel(LoggerLevel.INFO);
- assertThat(sut.isDebugEnabled()).isFalse();
- assertThat(sut.isTraceEnabled()).isFalse();
- sut.debug("message");
- sut.debug("message {}", "foo");
- sut.debug("message {} {}", "foo", "bar");
- sut.debug("message {} {} {}", "foo", "bar", "baz");
+ assertThat(underTest.isDebugEnabled()).isFalse();
+ assertThat(underTest.isTraceEnabled()).isFalse();
+ underTest.debug("message");
+ underTest.debug("message {}", "foo");
+ underTest.debug("message {} {}", "foo", "bar");
+ underTest.debug("message {} {} {}", "foo", "bar", "baz");
verifyZeroInteractions(stream);
}
@Test
public void trace_enabled() {
tester.setLevel(LoggerLevel.TRACE);
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isTrue();
- sut.trace("message");
- sut.trace("message {}", "foo");
- sut.trace("message {} {}", "foo", "bar");
- sut.trace("message {} {} {}", "foo", "bar", "baz");
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isTrue();
+ underTest.trace("message");
+ underTest.trace("message {}", "foo");
+ underTest.trace("message {} {}", "foo", "bar");
+ underTest.trace("message {} {} {}", "foo", "bar", "baz");
verify(stream, times(4)).println(anyString());
}
@Test
public void trace_disabled() {
tester.setLevel(LoggerLevel.DEBUG);
- assertThat(sut.isTraceEnabled()).isFalse();
- sut.trace("message");
- sut.trace("message {}", "foo");
- sut.trace("message {} {}", "foo", "bar");
- sut.trace("message {} {} {}", "foo", "bar", "baz");
+ assertThat(underTest.isTraceEnabled()).isFalse();
+ underTest.trace("message");
+ underTest.trace("message {}", "foo");
+ underTest.trace("message {} {}", "foo", "bar");
+ underTest.trace("message {} {} {}", "foo", "bar", "baz");
verifyZeroInteractions(stream);
}
@Test
public void log() {
- sut.info("message");
- sut.info("message {}", "foo");
- sut.info("message {} {}", "foo", "bar");
- sut.info("message {} {} {}", "foo", "bar", "baz");
+ underTest.info("message");
+ underTest.info("message {}", "foo");
+ underTest.info("message {} {}", "foo", "bar");
+ underTest.info("message {} {} {}", "foo", "bar", "baz");
verify(stream, times(4)).println(startsWith("INFO "));
- sut.warn("message");
- sut.warn("message {}", "foo");
- sut.warn("message {} {}", "foo", "bar");
- sut.warn("message {} {} {}", "foo", "bar", "baz");
+ underTest.warn("message");
+ underTest.warn("message {}", "foo");
+ underTest.warn("message {} {}", "foo", "bar");
+ underTest.warn("message {} {} {}", "foo", "bar", "baz");
verify(stream, times(4)).println(startsWith("WARN "));
- sut.error("message");
- sut.error("message {}", "foo");
- sut.error("message {} {}", "foo", "bar");
- sut.error("message {} {} {}", "foo", "bar", "baz");
- sut.error("message", new IllegalArgumentException());
+ underTest.error("message");
+ underTest.error("message {}", "foo");
+ underTest.error("message {} {}", "foo", "bar");
+ underTest.error("message {} {} {}", "foo", "bar", "baz");
+ underTest.error("message", new IllegalArgumentException());
verify(stream, times(5)).println(startsWith("ERROR "));
}
@Test
public void level_change_not_implemented_yet() {
- assertThat(sut.setLevel(LoggerLevel.DEBUG)).isFalse();
+ assertThat(underTest.setLevel(LoggerLevel.DEBUG)).isFalse();
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java
index 197225cf515..b58df58be8e 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/ConsoleLoggersTest.java
@@ -25,20 +25,20 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ConsoleLoggersTest {
- ConsoleLoggers sut = new ConsoleLoggers();
+ ConsoleLoggers underTest = new ConsoleLoggers();
@Test
public void newInstance() {
- Logger logger = sut.newInstance("foo");
+ Logger logger = underTest.newInstance("foo");
assertThat(logger).isInstanceOf(ConsoleLogger.class);
}
@Test
public void level() {
// INFO by default
- assertThat(sut.getLevel()).isEqualTo(LoggerLevel.INFO);
+ assertThat(underTest.getLevel()).isEqualTo(LoggerLevel.INFO);
- sut.setLevel(LoggerLevel.DEBUG);
- assertThat(sut.getLevel()).isEqualTo(LoggerLevel.DEBUG);
+ underTest.setLevel(LoggerLevel.DEBUG);
+ assertThat(underTest.getLevel()).isEqualTo(LoggerLevel.DEBUG);
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/DefaultProfilerTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/DefaultProfilerTest.java
index da6b46697e4..30d2e286b60 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/DefaultProfilerTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/DefaultProfilerTest.java
@@ -30,21 +30,21 @@ public class DefaultProfilerTest {
@Rule
public LogTester tester = new LogTester();
- Profiler sut = Profiler.create(Loggers.get("DefaultProfilerTest"));
+ Profiler underTest = Profiler.create(Loggers.get("DefaultProfilerTest"));
@Test
public void test_levels() throws Exception {
// trace by default
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isTrue();
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isTrue();
tester.setLevel(LoggerLevel.DEBUG);
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isFalse();
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isFalse();
tester.setLevel(LoggerLevel.INFO);
- assertThat(sut.isDebugEnabled()).isFalse();
- assertThat(sut.isTraceEnabled()).isFalse();
+ assertThat(underTest.isDebugEnabled()).isFalse();
+ assertThat(underTest.isTraceEnabled()).isFalse();
}
@Test
@@ -52,25 +52,25 @@ public class DefaultProfilerTest {
tester.setLevel(LoggerLevel.TRACE);
// trace
- sut.startTrace("Register rules");
+ underTest.startTrace("Register rules");
assertThat(tester.logs()).containsOnly("Register rules");
- sut.stopTrace();
+ underTest.stopTrace();
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(1)).startsWith("Register rules (done) | time=");
tester.clear();
// debug
- sut.startDebug("Register rules");
+ underTest.startDebug("Register rules");
assertThat(tester.logs()).containsOnly("Register rules");
- sut.stopTrace();
+ underTest.stopTrace();
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(1)).startsWith("Register rules (done) | time=");
tester.clear();
// info
- sut.startInfo("Register rules");
+ underTest.startInfo("Register rules");
assertThat(tester.logs()).containsOnly("Register rules");
- sut.stopTrace();
+ underTest.stopTrace();
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(1)).startsWith("Register rules (done) | time=");
}
@@ -80,24 +80,24 @@ public class DefaultProfilerTest {
tester.setLevel(LoggerLevel.TRACE);
// start TRACE and stop DEBUG
- sut.startTrace("Register rules");
- sut.stopDebug("Rules registered");
+ underTest.startTrace("Register rules");
+ underTest.stopDebug("Rules registered");
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(0)).contains("Register rules");
assertThat(tester.logs().get(1)).startsWith("Rules registered | time=");
tester.clear();
// start DEBUG and stop INFO
- sut.startDebug("Register rules");
- sut.stopInfo("Rules registered");
+ underTest.startDebug("Register rules");
+ underTest.stopInfo("Rules registered");
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(0)).contains("Register rules");
assertThat(tester.logs().get(1)).startsWith("Rules registered | time=");
tester.clear();
// start INFO and stop TRACE
- sut.startInfo("Register rules");
- sut.stopTrace("Rules registered");
+ underTest.startInfo("Register rules");
+ underTest.stopTrace("Rules registered");
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(0)).contains("Register rules");
assertThat(tester.logs().get(1)).startsWith("Rules registered | time=");
@@ -108,22 +108,22 @@ public class DefaultProfilerTest {
tester.setLevel(LoggerLevel.TRACE);
// trace
- sut.start();
- sut.stopTrace("Rules registered");
+ underTest.start();
+ underTest.stopTrace("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs().get(0)).startsWith("Rules registered | time=");
tester.clear();
// debug
- sut.start();
- sut.stopDebug("Rules registered");
+ underTest.start();
+ underTest.stopDebug("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs().get(0)).startsWith("Rules registered | time=");
tester.clear();
// info
- sut.start();
- sut.stopInfo("Rules registered");
+ underTest.start();
+ underTest.stopInfo("Rules registered");
assertThat(tester.logs()).hasSize(1);
assertThat(tester.logs().get(0)).startsWith("Rules registered | time=");
}
@@ -148,12 +148,12 @@ public class DefaultProfilerTest {
@Test
public void empty_message() {
- sut.addContext("foo", "bar");
- sut.startInfo("");
+ underTest.addContext("foo", "bar");
+ underTest.startInfo("");
assertThat(tester.logs()).containsOnly("foo=bar");
- sut.addContext("after_start", true);
- sut.stopInfo("");
+ underTest.addContext("after_start", true);
+ underTest.stopInfo("");
assertThat(tester.logs()).hasSize(2);
assertThat(tester.logs().get(1))
.startsWith("time=")
@@ -162,9 +162,9 @@ public class DefaultProfilerTest {
@Test
public void fail_if_stop_without_message() {
- sut.start();
+ underTest.start();
try {
- sut.stopInfo();
+ underTest.stopInfo();
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Profiler#stopXXX() can't be called without any message defined in start methods");
@@ -174,7 +174,7 @@ public class DefaultProfilerTest {
@Test
public void fail_if_stop_without_start() {
try {
- sut.stopDebug("foo");
+ underTest.stopDebug("foo");
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Profiler must be started before being stopped");
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogbackLoggerTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogbackLoggerTest.java
index 500b32b47d9..9061d429692 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogbackLoggerTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/log/LogbackLoggerTest.java
@@ -29,7 +29,7 @@ import static org.junit.Assert.fail;
public class LogbackLoggerTest {
- LogbackLogger sut = new LogbackLogger((ch.qos.logback.classic.Logger)LoggerFactory.getLogger(getClass()));
+ LogbackLogger underTest = new LogbackLogger((ch.qos.logback.classic.Logger)LoggerFactory.getLogger(getClass()));
@Rule
public LogTester tester = new LogTester();
@@ -37,55 +37,55 @@ public class LogbackLoggerTest {
@Test
public void log() {
// no assertions. Simply verify that calls do not fail.
- sut.trace("message");
- sut.trace("message {}", "foo");
- sut.trace("message {} {}", "foo", "bar");
- sut.trace("message {} {} {}", "foo", "bar", "baz");
-
- sut.debug("message");
- sut.debug("message {}", "foo");
- sut.debug("message {} {}", "foo", "bar");
- sut.debug("message {} {} {}", "foo", "bar", "baz");
-
- sut.info("message");
- sut.info("message {}", "foo");
- sut.info("message {} {}", "foo", "bar");
- sut.info("message {} {} {}", "foo", "bar", "baz");
-
- sut.warn("message");
- sut.warn("message {}", "foo");
- sut.warn("message {} {}", "foo", "bar");
- sut.warn("message {} {} {}", "foo", "bar", "baz");
-
- sut.error("message");
- sut.error("message {}", "foo");
- sut.error("message {} {}", "foo", "bar");
- sut.error("message {} {} {}", "foo", "bar", "baz");
- sut.error("message", new IllegalArgumentException(""));
+ underTest.trace("message");
+ underTest.trace("message {}", "foo");
+ underTest.trace("message {} {}", "foo", "bar");
+ underTest.trace("message {} {} {}", "foo", "bar", "baz");
+
+ underTest.debug("message");
+ underTest.debug("message {}", "foo");
+ underTest.debug("message {} {}", "foo", "bar");
+ underTest.debug("message {} {} {}", "foo", "bar", "baz");
+
+ underTest.info("message");
+ underTest.info("message {}", "foo");
+ underTest.info("message {} {}", "foo", "bar");
+ underTest.info("message {} {} {}", "foo", "bar", "baz");
+
+ underTest.warn("message");
+ underTest.warn("message {}", "foo");
+ underTest.warn("message {} {}", "foo", "bar");
+ underTest.warn("message {} {} {}", "foo", "bar", "baz");
+
+ underTest.error("message");
+ underTest.error("message {}", "foo");
+ underTest.error("message {} {}", "foo", "bar");
+ underTest.error("message {} {} {}", "foo", "bar", "baz");
+ underTest.error("message", new IllegalArgumentException(""));
}
@Test
public void change_level() {
- assertThat(sut.setLevel(LoggerLevel.INFO)).isTrue();
- assertThat(sut.logbackLogger().getLevel()).isEqualTo(Level.INFO);
- assertThat(sut.isDebugEnabled()).isFalse();
- assertThat(sut.isTraceEnabled()).isFalse();
-
- assertThat(sut.setLevel(LoggerLevel.DEBUG)).isTrue();
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isFalse();
- assertThat(sut.logbackLogger().getLevel()).isEqualTo(Level.DEBUG);
-
- assertThat(sut.setLevel(LoggerLevel.TRACE)).isTrue();
- assertThat(sut.isDebugEnabled()).isTrue();
- assertThat(sut.isTraceEnabled()).isTrue();
- assertThat(sut.logbackLogger().getLevel()).isEqualTo(Level.TRACE);
+ assertThat(underTest.setLevel(LoggerLevel.INFO)).isTrue();
+ assertThat(underTest.logbackLogger().getLevel()).isEqualTo(Level.INFO);
+ assertThat(underTest.isDebugEnabled()).isFalse();
+ assertThat(underTest.isTraceEnabled()).isFalse();
+
+ assertThat(underTest.setLevel(LoggerLevel.DEBUG)).isTrue();
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isFalse();
+ assertThat(underTest.logbackLogger().getLevel()).isEqualTo(Level.DEBUG);
+
+ assertThat(underTest.setLevel(LoggerLevel.TRACE)).isTrue();
+ assertThat(underTest.isDebugEnabled()).isTrue();
+ assertThat(underTest.isTraceEnabled()).isTrue();
+ assertThat(underTest.logbackLogger().getLevel()).isEqualTo(Level.TRACE);
}
@Test
public void info_level_can_not_be_disabled() {
try {
- sut.setLevel(LoggerLevel.ERROR);
+ underTest.setLevel(LoggerLevel.ERROR);
fail();
} catch (IllegalArgumentException e) {