import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
import java.util.Objects;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
-import org.sonar.db.component.ComponentDto;
import org.sonar.db.project.ProjectDto;
import static java.util.Objects.requireNonNull;
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.db.entity;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
}
if (!path.toFile().canRead()) {
throw new MessageException("Unable to configure: " + processProperty.getKey() + ". "
- + "Could not get read access to [" + processPropertyPath + "]");
+ + "Could not get read access to [" + processPropertyPath + "]");
}
return path.getFileName().toString();
}
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
-import java.util.Random;
import javax.annotation.Nullable;
import org.junit.After;
import org.junit.Rule;
File data = new File(foo, "data");
when(mockedEsInstallation.getDataDirectory()).thenReturn(data);
- EsSettings underTest = new EsSettings(minProps(new Random().nextBoolean()), mockedEsInstallation, system);
+ EsSettings underTest = new EsSettings(minProps(true), mockedEsInstallation, system);
Map<String, String> generated = underTest.build();
assertThat(generated)
@Test
@UseDataProvider("clusterEnabledOrNot")
public void enable_http_connector_on_specified_port(boolean clusterEnabled) throws Exception {
- String port = "" + new Random().nextInt(49151);
+ String port = "" + 49150;
Props props = minProps(clusterEnabled, null, port);
Map<String, String> settings = new EsSettings(props, new EsInstallation(props), System2.INSTANCE).build();
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.pattern.PatternLayoutEncoderBase;
-import com.google.common.collect.ImmutableMap;
import java.util.Map;
public class PatternLayoutEncoder extends PatternLayoutEncoderBase<ILoggingEvent> {
}
private static Map<String, String> getEscapedMessageConverterConfig() {
- return ImmutableMap.of(
+ return Map.of(
"m", EscapedMessageConverter.class.getName(),
"msg", EscapedMessageConverter.class.getName(),
"message", EscapedMessageConverter.class.getName());
import java.net.InetAddress;
import java.util.Map;
import java.util.Properties;
-import java.util.Random;
import org.junit.Test;
import org.sonar.core.extension.CoreExtension;
import org.sonar.core.extension.ServiceLoaderWrapper;
@Test
public void parseTimeoutMs_returns_long_from_value() {
- long expected = 1 + new Random().nextInt(5_999_663);
+ long expected = 5_999_664;
long res = parseTimeoutMs(ProcessProperties.Property.WEB_GRACEFUL_STOP_TIMEOUT, expected + "");
@Test
public void parseTimeoutMs_throws_ISE_if_value_is_less_than_0() {
- int timeoutValue = -(1 + new Random().nextInt(5_999_663));
+ int timeoutValue = -5_999_664;
assertThatThrownBy(() -> parseTimeoutMs(ProcessProperties.Property.WEB_GRACEFUL_STOP_TIMEOUT, timeoutValue + ""))
.isInstanceOf(IllegalStateException.class)
.hasMessage("value of WEB_GRACEFUL_STOP_TIMEOUT must be >= 1");
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.http;
+
+import javax.annotation.ParametersAreNonnullByDefault;
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@javax.annotation.ParametersAreNonnullByDefault
+package org.sonar.server.pushapi.hotspots;
userSession.logIn(user).setNonSystemAdministrator();
when(dispatchers.getGlobalDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
- assertThatThrownBy(() -> call(NOTIF_MY_NEW_ISSUES, null, null, user.getLogin()))
+ String login = user.getLogin();
+ assertThatThrownBy(() -> call(NOTIF_MY_NEW_ISSUES, null, null, login))
.isInstanceOf(ForbiddenException.class);
}
userSession.logIn(user);
when(dispatchers.getProjectDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES));
- assertThatThrownBy(() -> call(NOTIF_MY_NEW_ISSUES, null, project.getKey(), null))
+ String projectKey = project.getKey();
+ assertThatThrownBy(() -> call(NOTIF_MY_NEW_ISSUES, null, projectKey, null))
.isInstanceOf(ForbiddenException.class);
}
when(dispatchers.getGlobalDispatchers()).thenReturn(asList(NOTIF_MY_NEW_ISSUES, NOTIF_NEW_ISSUES));
when(dispatchers.getProjectDispatchers()).thenReturn(asList(NOTIF_MY_NEW_ISSUES, NOTIF_NEW_ISSUES));
- assertThatThrownBy(() -> call("Dispatcher42", null, project.getKey(), null))
+ String projectKey = project.getKey();
+ assertThatThrownBy(() -> call("Dispatcher42", null, projectKey, null))
.isInstanceOf(BadRequestException.class)
.hasMessageContaining("Value of parameter 'type' (Dispatcher42) must be one of: [Dispatcher1, Dispatcher2]");
}
when(dispatchers.getGlobalDispatchers()).thenReturn(asList(NOTIF_MY_NEW_ISSUES, NOTIF_NEW_ISSUES));
when(dispatchers.getProjectDispatchers()).thenReturn(asList(NOTIF_MY_NEW_ISSUES, NOTIF_NEW_ISSUES));
- assertThatThrownBy(() -> call("Dispatcher42", null, project.getKey(), null))
+ String projectKey = project.getKey();
+ assertThatThrownBy(() -> call("Dispatcher42", null, projectKey, null))
.isInstanceOf(BadRequestException.class)
.hasMessageContaining("Value of parameter 'type' (Dispatcher42) must be one of: [Dispatcher1, Dispatcher2]");
}
@Test
public void fail_when_no_dispatcher() {
- assertThatThrownBy(() -> ws.newRequest().execute())
+ TestRequest request = ws.newRequest();
+ assertThatThrownBy(request::execute)
.isInstanceOf(IllegalArgumentException.class);
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.almintegration.ws.github.config;
+
+import javax.annotation.ParametersAreNonnullByDefault;
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.management;
+
+import javax.annotation.ParametersAreNonnullByDefault;
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.newcodeperiod;
+
+import javax.annotation.ParametersAreNonnullByDefault;
*/
package org.sonar.server.permission.ws;
-import java.util.Optional;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
-import org.sonar.db.component.ComponentDto;
import org.sonar.db.entity.EntityDto;
import org.sonar.db.permission.template.PermissionTemplateDto;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.user.UserSession;
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdmin;
-import static org.sonar.server.permission.ws.ProjectWsRef.newWsProjectRef;
import static org.sonar.server.permission.ws.WsParameters.createProjectParameters;
import static org.sonar.server.permission.ws.WsParameters.createTemplateParameters;
import static org.sonar.server.permission.ws.template.WsTemplateRef.newTemplateRef;