use of org.sonar.api.utils.System2 in project sonarqube by SonarSource.
the class PersistIssuesStepTest method setup.
@Before
public void setup() throws Exception {
issueCache = new IssueCache(temp.newFile(), System2.INSTANCE);
system2 = mock(System2.class);
when(system2.now()).thenReturn(NOW);
reportReader.setMetadata(ScannerReport.Metadata.getDefaultInstance());
step = new PersistIssuesStep(dbClient, system2, new UpdateConflictResolver(), new RuleRepositoryImpl(dbClient), issueCache);
}
use of org.sonar.api.utils.System2 in project sonarqube by SonarSource.
the class IssueIndexDebtTest method setUp.
@Before
public void setUp() {
System2 system = mock(System2.class);
when(system.getDefaultTimeZone()).thenReturn(TimeZone.getTimeZone("+01:00"));
when(system.now()).thenReturn(System.currentTimeMillis());
index = new IssueIndex(tester.client(), system, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
}
use of org.sonar.api.utils.System2 in project sonarqube by SonarSource.
the class GroupsActionTest method setUp.
@Before
public void setUp() {
System2 system2 = new System2();
UserDao userDao = new UserDao(system2);
GroupDao groupDao = new GroupDao(system2);
UserGroupDao userGroupDao = new UserGroupDao();
GroupMembershipDao groupMembershipDao = new GroupMembershipDao();
dbClient = new DbClient(dbTester.database(), dbTester.myBatis(), userDao, groupDao, userGroupDao, groupMembershipDao);
session = dbClient.openSession(false);
session.commit();
tester = new WsTester(new UsersWs(new GroupsAction(dbClient, userSession)));
userSession.logIn().setSystemAdministrator();
}
use of org.sonar.api.utils.System2 in project sonarqube by SonarSource.
the class UserTokensWsTest method setUp.
@Before
public void setUp() {
UserSession userSession = mock(UserSession.class);
DbClient dbClient = mock(DbClient.class);
System2 system = mock(System2.class);
TokenGenerator tokenGenerator = mock(TokenGenerator.class);
ws = new WsTester(new UserTokensWs(new GenerateAction(dbClient, userSession, system, tokenGenerator), new RevokeAction(dbClient, userSession), new SearchAction(dbClient, userSession)));
}
use of org.sonar.api.utils.System2 in project sonarqube by SonarSource.
the class GlobalTempFolderProviderTest method createTempFolderDefault.
@Test
public void createTempFolderDefault() throws Exception {
System2 system = mock(System2.class);
tempFolderProvider = new GlobalTempFolderProvider(system);
File userHome = temp.newFolder();
when(system.envVariable("SONAR_USER_HOME")).thenReturn(null);
when(system.property("user.home")).thenReturn(userHome.getAbsolutePath().toString());
// if nothing is defined, it will be in {user.home}/.sonar/.sonartmp
File defaultSonarHome = new File(userHome.getAbsolutePath(), ".sonar");
File workingDir = new File(defaultSonarHome, CoreProperties.GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE).getAbsoluteFile();
try {
TempFolder tempFolder = tempFolderProvider.provide(new GlobalProperties(Collections.<String, String>emptyMap()));
tempFolder.newDir();
tempFolder.newFile();
assertThat(getCreatedTempDir(workingDir)).exists();
assertThat(getCreatedTempDir(workingDir).list()).hasSize(2);
} finally {
FileUtils.deleteQuietly(workingDir);
}
}
Aggregations