<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>server</artifactId>
<version>5.4-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
- <modelVersion>4.0.0</modelVersion>
<artifactId>sonar-process-monitor</artifactId>
<name>SonarQube :: Process Monitor</name>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>server</artifactId>
<version>5.4-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
- <modelVersion>4.0.0</modelVersion>
<artifactId>sonar-process</artifactId>
<name>SonarQube :: Process</name>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>server</artifactId>
<version>5.4-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
- <modelVersion>4.0.0</modelVersion>
<artifactId>sonar-search</artifactId>
<packaging>jar</packaging>
item.setUpdatedAt(now);
doUpdate(session, item);
if (hasIndex()) {
- session.enqueue(new UpsertDto<DTO>(getIndexType(), item));
+ session.enqueue(new UpsertDto<>(getIndexType(), item));
}
} catch (Exception e) {
throw new IllegalStateException("Fail to update item in db: " + item, e);
@Override
public DTO insert(DbSession session, DTO item, DTO... others) {
- insert(session, Lists.<DTO>asList(item, others));
+ insert(session, Lists.asList(item, others));
return item;
}
@Override
public void delete(DbSession session, DTO item, DTO... others) {
- delete(session, Lists.<DTO>asList(item, others));
+ delete(session, Lists.asList(item, others));
}
@Override
checkNameNotAnyone(name);
}
- private void checkNameLength(String name) {
+ private static void checkNameLength(String name) {
Preconditions.checkArgument(!name.isEmpty(), "Name cannot be empty");
Preconditions.checkArgument(name.length() <= NAME_MAX_LENGTH, String.format("Name cannot be longer than %d characters", NAME_MAX_LENGTH));
}
- private void checkNameNotAnyone(String name) {
+ private static void checkNameNotAnyone(String name) {
Preconditions.checkArgument(!DefaultGroups.isAnyone(name), String.format("Name '%s' is reserved (regardless of case)", DefaultGroups.ANYONE));
}
public class ServletResponse implements Response {
- private Map<String, String> headers = new HashMap<String, String>();
+ private Map<String, String> headers = new HashMap<>();
public static class ServletStream implements Stream {
private String mediaType;
} else // We need to check all the attributes for font changes
{
if (fonts == null)
- fonts = new HashMap<String, FontMetrics>();
+ fonts = new HashMap<>();
Element root = component.getDocument().getDefaultRootElement();
int index = root.getElementIndex(rowStartOffset);
private void writeSystemProps(BufferedWriter fileWriter) throws IOException {
fileWriter.write("System properties:\n");
Properties sysProps = system.properties();
- for (String prop : new TreeSet<String>(sysProps.stringPropertyNames())) {
+ for (String prop : new TreeSet<>(sysProps.stringPropertyNames())) {
if (prop.startsWith(SONAR_PROP_PREFIX)) {
continue;
}
private void writeEnvVariables(BufferedWriter fileWriter) throws IOException {
fileWriter.append("Environment variables:\n");
Map<String, String> envVariables = system.envVariables();
- for (String env : new TreeSet<String>(envVariables.keySet())) {
+ for (String env : new TreeSet<>(envVariables.keySet())) {
fileWriter.append(String.format(" - %s=%s", env, envVariables.get(env))).append('\n');
}
}
try (BufferedWriter fileWriter = Files.newBufferedWriter(analysisLog.toPath(), StandardCharsets.UTF_8, StandardOpenOption.WRITE, StandardOpenOption.APPEND)) {
fileWriter.append(String.format("Settings for module: %s", moduleDefinition.getKey())).append('\n');
Map<String, String> moduleSettings = settings.getProperties();
- for (String prop : new TreeSet<String>(moduleSettings.keySet())) {
+ for (String prop : new TreeSet<>(moduleSettings.keySet())) {
if (isSystemProp(prop) || isEnvVariable(prop) || !isSqProp(prop)) {
continue;
}
@Before
public void setUp() {
- HashMap<String, String> map = new HashMap<String, String>();
+ HashMap<String, String> map = new HashMap<>();
map.put("sonar.userHome", temp.getRoot().getAbsolutePath());
globalProperties = new GlobalProperties(map);
provider = new GlobalPersistentCacheProvider();
@Test
public void readRealResponse() throws IOException {
InputStream is = getTestResource("project.protobuf");
- when(wsLoader.loadStream(anyString())).thenReturn(new WSLoaderResult<InputStream>(is, true));
+ when(wsLoader.loadStream(anyString())).thenReturn(new WSLoaderResult<>(is, true));
ProjectRepositories proj = loader.load("org.sonarsource.github:sonar-github-plugin", true, null);
FileData fd = proj.fileData("org.sonarsource.github:sonar-github-plugin",
@Test
public void testNoProfile() throws IOException {
InputStream is = createEncodedQP();
- when(ws.loadStream(anyString())).thenReturn(new WSLoaderResult<InputStream>(is, false));
+ when(ws.loadStream(anyString())).thenReturn(new WSLoaderResult<>(is, false));
exception.expect(MessageException.class);
exception.expectMessage("No quality profiles");
@Test
public void use_real_response() throws IOException {
InputStream is = getTestResource("quality_profile_search_default");
- when(ws.loadStream(anyString())).thenReturn(new WSLoaderResult<InputStream>(is, false));
+ when(ws.loadStream(anyString())).thenReturn(new WSLoaderResult<>(is, false));
List<QualityProfile> loaded = qpLoader.loadDefault(null, null);
verify(ws).loadStream("/api/qualityprofiles/search.protobuf?defaults=true");
public void testError() throws IOException {
InputStream is = mock(InputStream.class);
when(is.read()).thenThrow(IOException.class);
- when(wsLoader.loadStream("/batch/issues.protobuf?key=foo")).thenReturn(new WSLoaderResult<InputStream>(is, true));
+ when(wsLoader.loadStream("/batch/issues.protobuf?key=foo")).thenReturn(new WSLoaderResult<>(is, true));
loader.load("foo", mock(Function.class));
}
}
when(key.get()).thenReturn("project");
when(projectRepo.exists()).thenReturn(true);
- response = new ArrayList<QualityProfile>(1);
+ response = new ArrayList<>(1);
response.add(QualityProfile.newBuilder().setKey("profile").setName("profile").setLanguage("lang").build());
}
String req1 = "/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=c%2B-test_c%2B-values-17445&p=1&ps=500";
String req2 = "/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=c%2B-test_c%2B-values-17445&p=2&ps=500";
- when(ws.loadStream(req1)).thenReturn(new WSLoaderResult<InputStream>(response1, false));
- when(ws.loadStream(req2)).thenReturn(new WSLoaderResult<InputStream>(response2, false));
+ when(ws.loadStream(req1)).thenReturn(new WSLoaderResult<>(response1, false));
+ when(ws.loadStream(req2)).thenReturn(new WSLoaderResult<>(response2, false));
Collection<LoadedActiveRule> activeRules = loader.load("c+-test_c+-values-17445", null);
assertThat(activeRules).hasSize(226);
public class WebCodeColorizerFormat extends CodeColorizerFormat {
- private final List<Tokenizer> tokenizers = new ArrayList<Tokenizer>();
+ private final List<Tokenizer> tokenizers = new ArrayList<>();
public WebCodeColorizerFormat() {
super("web");
}
private static Map<String, Collection<String>> getTestUserGroupMapping() {
- Map<String, Collection<String>> userGroupsMap = new HashMap<String, Collection<String>>();
+ Map<String, Collection<String>> userGroupsMap = new HashMap<>();
addUserGroupMapping(userGroupsMap, "userWithOneGroups", new String[] {"group1"});
addUserGroupMapping(userGroupsMap, "userWithTwoGroups", new String[] {"group1", "group2"});
addUserGroupMapping(userGroupsMap, "userWithNoGroup", new String[] {});
private static void addUserGroupMapping(Map<String, Collection<String>> userGroupsMap, String user, @Nullable String[] groups) {
Collection<String> groupsCollection = null;
if (groups != null) {
- groupsCollection = new ArrayList<String>();
+ groupsCollection = new ArrayList<>();
groupsCollection.addAll(Arrays.asList(groups));
}