use of org.sonar.api.utils.System2 in project sonarqube by SonarSource.
the class AnalysisContextReportPublisherTest method prepare.
@Before
public void prepare() throws Exception {
logTester.setLevel(LoggerLevel.INFO);
system2 = mock(System2.class);
when(system2.properties()).thenReturn(new Properties());
projectRepos = mock(ProjectRepositories.class);
globalSettings = mock(GlobalSettings.class);
publisher = new AnalysisContextReportPublisher(analysisMode, pluginRepo, system2, projectRepos, globalSettings);
}
use of org.sonar.api.utils.System2 in project sonarqube by SonarSource.
the class CreateDefaultOrganization method saveDefaultOrganizationUuid.
private void saveDefaultOrganizationUuid(Context context, String uuid) throws SQLException {
Select select = context.prepareSelect("select kee from internal_properties where kee=?");
select.setString(1, INTERNAL_PROPERTY_DEFAULT_ORGANIZATION);
if (select.get(row -> row.getNullableString(1)) == null) {
context.prepareUpsert("insert into internal_properties" + " (kee, is_empty, text_value, created_at)" + " values" + " (?, ?, ?, ?)").setString(1, INTERNAL_PROPERTY_DEFAULT_ORGANIZATION).setBoolean(2, false).setString(3, uuid).setLong(4, system2.now()).execute().commit();
}
}
use of org.sonar.api.utils.System2 in project sonarqube by SonarSource.
the class PersistTestsStepTest method setup.
@Before
public void setup() {
System2 system2 = mock(System2.class);
when(system2.now()).thenReturn(now);
underTest = new PersistTestsStep(dbClient, system2, reportReader, treeRootHolder);
root = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren(ReportComponent.builder(Component.Type.MODULE, 2).setUuid("MODULE_UUID").setKey("MODULE_KEY").addChildren(ReportComponent.builder(Component.Type.FILE, 3).setUuid(TEST_FILE_UUID_1).setKey("TEST_FILE1_KEY").setFileAttributes(new FileAttributes(true, null, 1)).build(), ReportComponent.builder(Component.Type.FILE, 4).setUuid(TEST_FILE_UUID_2).setKey("TEST_FILE2_KEY").setFileAttributes(new FileAttributes(true, null, 1)).build(), ReportComponent.builder(Component.Type.FILE, 5).setUuid(MAIN_FILE_UUID_1).setKey("MAIN_FILE1_KEY").build(), ReportComponent.builder(Component.Type.FILE, 6).setUuid(MAIN_FILE_UUID_2).setKey("MAIN_FILE2_KEY").build()).build()).build();
treeRootHolder.setRoot(root);
}
use of org.sonar.api.utils.System2 in project sonarqube by SonarSource.
the class IssueIndexTest method setUp.
@Before
public void setUp() {
System2 system = mock(System2.class);
when(system.getDefaultTimeZone()).thenReturn(TimeZone.getTimeZone("GMT-1:00"));
when(system.now()).thenReturn(System.currentTimeMillis());
underTest = new IssueIndex(tester.client(), system, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
}
use of org.sonar.api.utils.System2 in project sonarqube by SonarSource.
the class SearchHistoryActionTest method inclusive_from_and_to_dates.
@Test
public void inclusive_from_and_to_dates() {
project = db.components().insertProject();
userSession.addProjectUuidPermissions(UserRole.USER, project.uuid());
List<String> analysisDates = LongStream.rangeClosed(1, 9).mapToObj(i -> dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setCreatedAt(System2.INSTANCE.now() + i * 1_000_000_000L))).peek(a -> dbClient.measureDao().insert(dbSession, newMeasureDto(complexityMetric, project, a).setValue(Double.valueOf(a.getCreatedAt())))).map(a -> formatDateTime(a.getCreatedAt())).collect(Collectors.toList());
db.commit();
wsRequest.setComponent(project.getKey()).setFrom(analysisDates.get(1)).setTo(analysisDates.get(3));
SearchHistoryResponse result = call();
assertThat(result.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal).containsExactly(1, 100, 3);
assertThat(result.getMeasures(0).getHistoryList()).extracting(HistoryValue::getDate).containsExactly(analysisDates.get(1), analysisDates.get(2), analysisDates.get(3));
}
Aggregations