aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMichal Duda <michal.duda@sonarsource.com>2020-12-11 12:13:49 +0100
committersonartech <sonartech@sonarsource.com>2020-12-22 20:09:36 +0000
commitbb0b4b79e4a6142ff259b038c2534f8420976e88 (patch)
tree8d29b3fbb3aa582059f7f5f4765351180984fca7 /server
parentf1c02b0e08b143d9135b797b07462c3108149b19 (diff)
downloadsonarqube-bb0b4b79e4a6142ff259b038c2534f8420976e88.tar.gz
sonarqube-bb0b4b79e4a6142ff259b038c2534f8420976e88.zip
SONAR-13999 remove orgs from issue WS
Diffstat (limited to 'server')
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java13
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AuthorsAction.java29
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java21
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java7
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java13
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AssignActionTest.java14
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssueChangeWSSupportTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionActionTest.java19
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java19
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AuthorsActionTest.java45
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java5
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ComponentTagsActionTest.java19
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java27
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionFacetsTest.java14
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java123
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java9
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/assigned_to_me_facet_sticky.json1
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/author_is_hidden.json1
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/components_contains_sub_projects.json3
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_facets.json1
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_facets_effort.json1
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_zero_facets.json1
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_main_scope.json4
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_main_scope_2.json4
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_test_scope.json3
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/issue_on_removed_file.json3
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/load_additional_fields_with_issue_admin_permission.json1
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/response_contains_all_fields_except_additional_fields.json1
-rw-r--r--server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/result_for_rule_search.json5
33 files changed, 123 insertions, 307 deletions
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
index ebf02698f04..7284a46c23d 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
@@ -147,7 +147,6 @@ public class ComponentTesting {
return newProjectDto(organizationDto.getUuid(), uuid, true);
}
-
public static ComponentDto newPublicProjectDto() {
return newProjectDto(Uuids.createFast(), false);
}
@@ -158,6 +157,10 @@ public class ComponentTesting {
return newProjectDto(organizationDto.getUuid(), Uuids.createFast(), false);
}
+ public static ComponentDto newPublicProjectDto(String uuid) {
+ return newProjectDto(uuid, false);
+ }
+
// TODO remove
@Deprecated
public static ComponentDto newPublicProjectDto(OrganizationDto organizationDto, String uuid) {
@@ -222,10 +225,10 @@ public class ComponentTesting {
public static ComponentDto newView(String uuid) {
return newPrivateProjectDto(uuid)
- .setUuid(uuid)
- .setScope(Scopes.PROJECT)
- .setQualifier(Qualifiers.VIEW)
- .setPrivate(false);
+ .setUuid(uuid)
+ .setScope(Scopes.PROJECT)
+ .setQualifier(Qualifiers.VIEW)
+ .setPrivate(false);
}
@Deprecated
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AuthorsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AuthorsAction.java
index 06576d059cf..5112615f1f3 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AuthorsAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/AuthorsAction.java
@@ -37,12 +37,10 @@ import org.sonar.api.server.ws.WebService.NewAction;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
import org.sonar.server.issue.index.IssueQuery;
-import org.sonar.server.organization.DefaultOrganizationProvider;
import org.sonar.server.user.UserSession;
import org.sonarqube.ws.Issues.AuthorsResponse;
@@ -50,14 +48,12 @@ import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Optional.ofNullable;
import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE;
import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
-import static org.sonar.server.exceptions.NotFoundException.checkFoundWithOptional;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
public class AuthorsAction implements IssuesWsAction {
private static final EnumSet<RuleType> ALL_RULE_TYPES_EXCEPT_SECURITY_HOTSPOTS = EnumSet.complementOf(EnumSet.of(RuleType.SECURITY_HOTSPOT));
- private static final String PARAM_ORGANIZATION = "organization";
private static final String PARAM_PROJECT = "project";
private final UserSession userSession;
@@ -65,18 +61,15 @@ public class AuthorsAction implements IssuesWsAction {
private final IssueIndex issueIndex;
private final IssueIndexSyncProgressChecker issueIndexSyncProgressChecker;
private final ComponentFinder componentFinder;
- private final DefaultOrganizationProvider defaultOrganizationProvider;
public AuthorsAction(UserSession userSession, DbClient dbClient, IssueIndex issueIndex,
IssueIndexSyncProgressChecker issueIndexSyncProgressChecker,
- ComponentFinder componentFinder,
- DefaultOrganizationProvider defaultOrganizationProvider) {
+ ComponentFinder componentFinder) {
this.userSession = userSession;
this.dbClient = dbClient;
this.issueIndex = issueIndex;
this.issueIndexSyncProgressChecker = issueIndexSyncProgressChecker;
this.componentFinder = componentFinder;
- this.defaultOrganizationProvider = defaultOrganizationProvider;
}
@Override
@@ -93,13 +86,6 @@ public class AuthorsAction implements IssuesWsAction {
action.createSearchQuery("luke", "authors");
action.createPageSize(10, 100);
- action.createParam(PARAM_ORGANIZATION)
- .setDescription("Organization key")
- .setRequired(false)
- .setInternal(true)
- .setExampleValue("my-org")
- .setSince("7.4");
-
action.createParam(PARAM_PROJECT)
.setDescription("Project key")
.setRequired(false)
@@ -111,10 +97,9 @@ public class AuthorsAction implements IssuesWsAction {
public void handle(Request request, Response response) throws Exception {
userSession.checkLoggedIn();
try (DbSession dbSession = dbClient.openSession(false)) {
- OrganizationDto organization = getOrganization(dbSession, request.param(PARAM_ORGANIZATION));
checkIfComponentNeedIssueSync(dbSession, request.param(PARAM_PROJECT));
- Optional<ComponentDto> project = getProject(dbSession, organization, request.param(PARAM_PROJECT));
+ Optional<ComponentDto> project = getProject(dbSession, request.param(PARAM_PROJECT));
List<String> authors = getAuthors(project.orElse(null), request);
AuthorsResponse wsResponse = AuthorsResponse.newBuilder().addAllAuthors(authors).build();
writeProtobuf(wsResponse, request, response);
@@ -129,20 +114,12 @@ public class AuthorsAction implements IssuesWsAction {
}
}
- private OrganizationDto getOrganization(DbSession dbSession, @Nullable String organizationKey) {
- String organizationOrDefaultKey = ofNullable(organizationKey).orElseGet(defaultOrganizationProvider.get()::getKey);
- return checkFoundWithOptional(
- dbClient.organizationDao().selectByKey(dbSession, organizationOrDefaultKey),
- "No organization with key '%s'", organizationOrDefaultKey);
- }
-
- private Optional<ComponentDto> getProject(DbSession dbSession, OrganizationDto organization, @Nullable String projectKey) {
+ private Optional<ComponentDto> getProject(DbSession dbSession, @Nullable String projectKey) {
if (projectKey == null) {
return Optional.empty();
}
ComponentDto project = componentFinder.getByKey(dbSession, projectKey);
checkArgument(project.scope().equals(Scopes.PROJECT), "Component '%s' must be a project", projectKey);
- checkArgument(project.getOrganizationUuid().equals(organization.getUuid()), "Project '%s' is not part of the organization '%s'", projectKey, organization.getKey());
return Optional.of(project);
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
index f81e3f4b4a5..5690a25809e 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
@@ -115,7 +115,6 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ISSUES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_LANGUAGES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_MODULE_UUIDS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ON_COMPONENT_ONLY;
-import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_OWASP_TOP_10;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PROJECTS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PULL_REQUEST;
@@ -380,13 +379,6 @@ public class SearchAction implements IssuesWsAction {
.setDescription("Pull request id. Not available in the community edition.")
.setExampleValue(KEY_PULL_REQUEST_EXAMPLE_001)
.setSince("7.1");
-
- action.createParam(PARAM_ORGANIZATION)
- .setDescription("Organization key")
- .setRequired(false)
- .setInternal(true)
- .setExampleValue("my-org")
- .setSince("6.4");
}
@Override
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java
index fff99e6c79c..0f669b47c15 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseData.java
@@ -34,7 +34,6 @@ import javax.annotation.Nullable;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.issue.IssueChangeDto;
import org.sonar.db.issue.IssueDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.db.user.UserDto;
import org.sonar.server.issue.workflow.Transition;
@@ -51,13 +50,11 @@ public class SearchResponseData {
private Long effortTotal = null;
private final Map<String, UserDto> usersByUuid = new HashMap<>();
private final List<RuleDefinitionDto> rules = new ArrayList<>();
- private final Map<String, String> organizationKeysByUuid = new HashMap<>();
private final Map<String, ComponentDto> componentsByUuid = new HashMap<>();
private final ListMultimap<String, IssueChangeDto> commentsByIssueKey = ArrayListMultimap.create();
private final ListMultimap<String, String> actionsByIssueKey = ArrayListMultimap.create();
private final ListMultimap<String, Transition> transitionsByIssueKey = ArrayListMultimap.create();
private final Set<String> updatableComments = new HashSet<>();
- private final Set<String> userOrganizationUuids = new HashSet<>();
public SearchResponseData(IssueDto issue) {
checkNotNull(issue);
@@ -94,12 +91,6 @@ public class SearchResponseData {
return rules;
}
- public String getOrganizationKey(String organizationUuid) {
- String organizationKey = organizationKeysByUuid.get(organizationUuid);
- checkNotNull(organizationKey, "Organization for uuid '%s' not found", organizationUuid);
- return organizationKey;
- }
-
@CheckForNull
List<IssueChangeDto> getCommentsForIssueKey(String issueKey) {
if (commentsByIssueKey.containsKey(issueKey)) {
@@ -175,18 +166,6 @@ public class SearchResponseData {
this.effortTotal = effortTotal;
}
- void addOrganization(OrganizationDto organizationDto) {
- this.organizationKeysByUuid.put(organizationDto.getUuid(), organizationDto.getKey());
- }
-
- void setUserOrganizationUuids(Set<String> organizationUuids) {
- this.userOrganizationUuids.addAll(organizationUuids);
- }
-
- Set<String> getUserOrganizationUuids() {
- return this.userOrganizationUuids;
- }
-
@CheckForNull
UserDto getUserByUuid(@Nullable String userUuid) {
return usersByUuid.get(userUuid);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
index 0b737cfcfd3..a55032b19fd 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
@@ -173,7 +173,6 @@ public class SearchResponseFormat {
issueBuilder.setType(Common.RuleType.forNumber(dto.getType()));
ComponentDto component = data.getComponentByUuid(dto.getComponentUuid());
- issueBuilder.setOrganization(data.getOrganizationKey(component.getOrganizationUuid()));
issueBuilder.setComponent(component.getKey());
ofNullable(component.getBranch()).ifPresent(issueBuilder::setBranch);
ofNullable(component.getPullRequest()).ifPresent(issueBuilder::setPullRequest);
@@ -207,10 +206,7 @@ public class SearchResponseFormat {
ofNullable(emptyToNull(dto.getChecksum())).ifPresent(issueBuilder::setHash);
completeIssueLocations(dto, issueBuilder, data);
- // Filter author only if user is member of the organization
- if (data.getUserOrganizationUuids().contains(component.getOrganizationUuid())) {
- issueBuilder.setAuthor(nullToEmpty(dto.getAuthorLogin()));
- }
+ issueBuilder.setAuthor(nullToEmpty(dto.getAuthorLogin()));
ofNullable(dto.getIssueCreationDate()).map(DateUtils::formatDateTime).ifPresent(issueBuilder::setCreationDate);
ofNullable(dto.getIssueUpdateDate()).map(DateUtils::formatDateTime).ifPresent(issueBuilder::setUpdateDate);
ofNullable(dto.getIssueCloseDate()).map(DateUtils::formatDateTime).ifPresent(issueBuilder::setCloseDate);
@@ -310,7 +306,6 @@ public class SearchResponseFormat {
for (ComponentDto dto : components) {
String uuid = dto.uuid();
Component.Builder builder = Component.newBuilder()
- .setOrganization(data.getOrganizationKey(dto.getOrganizationUuid()))
.setKey(dto.getKey())
.setUuid(uuid)
.setQualifier(dto.qualifier())
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
index e44cff2e985..9c7c0e86de4 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
@@ -97,7 +97,6 @@ public class SearchResponseLoader {
loadComments(collector, dbSession, fields, result);
loadUsers(preloadedResponseData, collector, dbSession, result);
loadComponents(preloadedResponseData, collector, dbSession, result);
- loadOrganizations(dbSession, result);
loadActionsAndTransitions(result, fields);
completeTotalEffortFromFacet(facets, result);
return result;
@@ -188,18 +187,6 @@ public class SearchResponseLoader {
return userSession.isLoggedIn() && requireNonNull(userSession.getUuid(), "User uuid should not be null").equals(dto.getUserUuid());
}
- private void loadOrganizations(DbSession dbSession, SearchResponseData result) {
- Collection<ComponentDto> components = result.getComponents();
- dbClient.organizationDao().selectByUuids(
- dbSession,
- components.stream().map(ComponentDto::getOrganizationUuid).collect(MoreCollectors.toSet()))
- .forEach(result::addOrganization);
-
- if (userSession.isLoggedIn()) {
- result.setUserOrganizationUuids(dbClient.organizationMemberDao().selectOrganizationUuidsByUser(dbSession, userSession.getUuid()));
- }
- }
-
private void loadActionsAndTransitions(SearchResponseData result, Set<SearchAdditionalField> fields) {
if (fields.contains(ACTIONS) || fields.contains(TRANSITIONS)) {
Map<String, ComponentDto> componentsByProjectUuid = result.getComponents()
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AssignActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AssignActionTest.java
index 7cca0cbb882..3b582319d60 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AssignActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/AssignActionTest.java
@@ -33,7 +33,6 @@ import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.IssueChangeContext;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.user.UserDto;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.tester.UserSessionRule;
@@ -57,24 +56,21 @@ public class AssignActionTest {
@Rule
public DbTester db = DbTester.create();
- private IssueChangeContext issueChangeContext = IssueChangeContext.createUser(new Date(), "user_uuid");
- private DefaultIssue issue = new DefaultIssue().setKey("ABC").setAssigneeUuid(ISSUE_CURRENT_ASSIGNEE_UUID);
+ private final IssueChangeContext issueChangeContext = IssueChangeContext.createUser(new Date(), "user_uuid");
+ private final DefaultIssue issue = new DefaultIssue().setKey("ABC").setAssigneeUuid(ISSUE_CURRENT_ASSIGNEE_UUID);
private Action.Context context;
- private OrganizationDto issueOrganizationDto;
- private AssignAction underTest = new AssignAction(db.getDbClient(), new IssueFieldsSetter());
+ private final AssignAction underTest = new AssignAction(db.getDbClient(), new IssueFieldsSetter());
@Before
- public void setUp() throws Exception {
- issueOrganizationDto = db.organizations().insert();
- ComponentDto project = db.components().insertPrivateProject(issueOrganizationDto);
+ public void setUp() {
+ ComponentDto project = db.components().insertPrivateProject();
context = new ActionContext(issue, issueChangeContext, project);
}
@Test
public void assign_issue() {
UserDto assignee = db.users().insertUser("john");
- db.organizations().addMember(issueOrganizationDto, assignee);
Map<String, Object> properties = new HashMap<>(ImmutableMap.of("assignee", "john"));
underTest.verify(properties, Collections.emptyList(), userSession);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssueChangeWSSupportTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssueChangeWSSupportTest.java
index c9b99c2e3ab..9f0124cf62f 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssueChangeWSSupportTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssueChangeWSSupportTest.java
@@ -43,7 +43,6 @@ import org.sonar.db.component.ComponentTesting;
import org.sonar.db.issue.IssueChangeDto;
import org.sonar.db.issue.IssueDto;
import org.sonar.db.issue.IssueTesting;
-import org.sonar.db.organization.OrganizationTesting;
import org.sonar.db.user.UserDto;
import org.sonar.markdown.Markdown;
import org.sonar.server.issue.IssueChangeWSSupport.FormattingContext;
@@ -579,8 +578,7 @@ public class IssueChangeWSSupportTest {
.extracting(Comment::getKey, Comment::hasMarkdown, Comment::hasHtmlText)
.containsExactlyInAnyOrder(
tuple(withText.getKey(), true, true),
- tuple(noText.getKey(), false, false)
- );
+ tuple(noText.getKey(), false, false));
assertThat(comments.stream().filter(Comment::hasHtmlText))
.extracting(Comment::getMarkdown, Comment::getHtmlText)
.containsOnly(tuple(withText.getChangeData(), Markdown.convertToHtml(withText.getChangeData())));
@@ -603,7 +601,7 @@ public class IssueChangeWSSupportTest {
}
private ComponentDto insertFile() {
- return dbTester.components().insertComponent(ComponentTesting.newFileDto(ComponentTesting.newPublicProjectDto(OrganizationTesting.newOrganizationDto())));
+ return dbTester.components().insertComponent(ComponentTesting.newFileDto(ComponentTesting.newPublicProjectDto()));
}
private static IssueChangeDto newComment(IssueDto issue) {
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionActionTest.java
index febb23e63bd..c45423c2daf 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/TransitionActionTest.java
@@ -35,7 +35,6 @@ import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
import org.sonar.db.issue.IssueDto;
import org.sonar.db.issue.IssueTesting;
-import org.sonar.db.organization.OrganizationTesting;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.server.issue.workflow.FunctionExecutor;
import org.sonar.server.issue.workflow.IssueWorkflow;
@@ -58,14 +57,12 @@ public class TransitionActionTest {
@Rule
public UserSessionRule userSession = UserSessionRule.standalone();
- private IssueFieldsSetter updater = new IssueFieldsSetter();
- private IssueWorkflow workflow = new IssueWorkflow(new FunctionExecutor(updater), updater);
- private TransitionService transitionService = new TransitionService(userSession, workflow);
-
- private Action.Context context = mock(Action.Context.class);
- private DefaultIssue issue = newIssue().toDefaultIssue();
-
- private TransitionAction action = new TransitionAction(transitionService);
+ private final IssueFieldsSetter updater = new IssueFieldsSetter();
+ private final IssueWorkflow workflow = new IssueWorkflow(new FunctionExecutor(updater), updater);
+ private final TransitionService transitionService = new TransitionService(userSession, workflow);
+ private final Action.Context context = mock(Action.Context.class);
+ private final DefaultIssue issue = newIssue().toDefaultIssue();
+ private final TransitionAction action = new TransitionAction(transitionService);
@Before
public void setUp() {
@@ -121,13 +118,13 @@ public class TransitionActionTest {
private IssueDto newIssue() {
RuleDefinitionDto rule = newRule().setUuid(Uuids.createFast());
- ComponentDto project = ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto());
+ ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto file = (newFileDto(project));
return IssueTesting.newIssue(rule, project, file);
}
private void loginAndAddProjectPermission(String login, String permission) {
- userSession.logIn(login).addProjectPermission(permission, ComponentTesting.newPrivateProjectDto(OrganizationTesting.newOrganizationDto(), issue.projectUuid()));
+ userSession.logIn(login).addProjectPermission(permission, ComponentTesting.newPrivateProjectDto(issue.projectUuid()));
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java
index 3e3e655e708..5dc6b454e63 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java
@@ -24,11 +24,11 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import org.junit.Test;
+import org.sonar.api.impl.utils.TestSystem2;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.Duration;
import org.sonar.api.utils.System2;
-import org.sonar.api.impl.utils.TestSystem2;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.DefaultIssueComment;
import org.sonar.core.issue.IssueChangeContext;
@@ -37,10 +37,8 @@ import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.issue.IssueDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.server.issue.index.IssueIndexer;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.rule.DefaultRuleFinder;
import static java.util.Collections.singletonList;
@@ -53,21 +51,19 @@ import static org.sonar.db.issue.IssueTesting.newIssue;
public class WebIssueStorageTest {
- private System2 system2 = new TestSystem2().setNow(2_000_000_000L);
+ private final System2 system2 = new TestSystem2().setNow(2_000_000_000L);
@org.junit.Rule
public DbTester db = DbTester.create(system2);
- private DbClient dbClient = db.getDbClient();
-
- private IssueIndexer issueIndexer = mock(IssueIndexer.class);
- private WebIssueStorage underTest = new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(db.getDbClient()), issueIndexer,
+ private final DbClient dbClient = db.getDbClient();
+ private final IssueIndexer issueIndexer = mock(IssueIndexer.class);
+ private final WebIssueStorage underTest = new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(db.getDbClient()), issueIndexer,
new SequenceUuidFactory());
@Test
public void load_component_id_from_db() {
- OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto project = db.components().insertPrivateProject(organizationDto);
+ ComponentDto project = db.components().insertPrivateProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
String componentUuid = underTest.component(db.getSession(), new DefaultIssue().setComponentUuid(file.uuid())).uuid();
@@ -77,8 +73,7 @@ public class WebIssueStorageTest {
@Test
public void load_project_id_from_db() {
- OrganizationDto organizationDto = db.organizations().insert();
- ComponentDto project = db.components().insertPrivateProject(organizationDto);
+ ComponentDto project = db.components().insertPrivateProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
String projectUuid = underTest.project(db.getSession(), new DefaultIssue().setProjectUuid(project.uuid())).uuid();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
index e96389815e4..68250630a1f 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
@@ -261,9 +261,7 @@ public class AssignActionTest {
}
private UserDto insertUser(String login) {
- UserDto user = db.users().insertUser(login);
- db.organizations().addMember(db.getDefaultOrganization(), user);
- return user;
+ return db.users().insertUser(login);
}
private IssueDto newIssue(String assignee) {
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AuthorsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AuthorsActionTest.java
index 4dc5f616ec5..cae79a549e1 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AuthorsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AuthorsActionTest.java
@@ -28,18 +28,16 @@ import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ResourceTypesRule;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.es.EsTester;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.exceptions.UnauthorizedException;
+import org.sonar.server.issue.index.AsyncIssueIndexing;
import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
import org.sonar.server.issue.index.IssueIndexer;
import org.sonar.server.issue.index.IssueIteratorFactory;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.permission.index.PermissionIndexerTester;
import org.sonar.server.permission.index.WebAuthorizationTypeSupport;
import org.sonar.server.tester.UserSessionRule;
@@ -72,16 +70,15 @@ public class AuthorsActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private IssueIndex issueIndex = new IssueIndex(es.client(), System2.INSTANCE, userSession, new WebAuthorizationTypeSupport(userSession));
- private IssueIndexer issueIndexer = new IssueIndexer(es.client(), db.getDbClient(), new IssueIteratorFactory(db.getDbClient()), null);
- private PermissionIndexerTester permissionIndexer = new PermissionIndexerTester(es, issueIndexer);
- private ViewIndexer viewIndexer = new ViewIndexer(db.getDbClient(), es.client());
- private IssueIndexSyncProgressChecker issueIndexSyncProgressChecker = mock(IssueIndexSyncProgressChecker.class);
- private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(PROJECT);
-
- private WsActionTester ws = new WsActionTester(new AuthorsAction(userSession, db.getDbClient(), issueIndex,
- issueIndexSyncProgressChecker, new ComponentFinder(db.getDbClient(), resourceTypes), defaultOrganizationProvider));
+ private final IssueIndex issueIndex = new IssueIndex(es.client(), System2.INSTANCE, userSession, new WebAuthorizationTypeSupport(userSession));
+ private final AsyncIssueIndexing asyncIssueIndexing = mock(AsyncIssueIndexing.class);
+ private final IssueIndexer issueIndexer = new IssueIndexer(es.client(), db.getDbClient(), new IssueIteratorFactory(db.getDbClient()), asyncIssueIndexing);
+ private final PermissionIndexerTester permissionIndexer = new PermissionIndexerTester(es, issueIndexer);
+ private final ViewIndexer viewIndexer = new ViewIndexer(db.getDbClient(), es.client());
+ private final IssueIndexSyncProgressChecker issueIndexSyncProgressChecker = mock(IssueIndexSyncProgressChecker.class);
+ private final ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(PROJECT);
+ private final WsActionTester ws = new WsActionTester(new AuthorsAction(userSession, db.getDbClient(), issueIndex,
+ issueIndexSyncProgressChecker, new ComponentFinder(db.getDbClient(), resourceTypes)));
@Test
public void search_authors() {
@@ -126,9 +123,8 @@ public class AuthorsActionTest {
public void search_authors_by_project() {
String leia = "leia.organa";
String luke = "luke.skywalker";
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project1 = db.components().insertPrivateProject(organization);
- ComponentDto project2 = db.components().insertPrivateProject(organization);
+ ComponentDto project1 = db.components().insertPrivateProject();
+ ComponentDto project2 = db.components().insertPrivateProject();
permissionIndexer.allowOnlyAnyone(project1, project2);
RuleDefinitionDto rule = db.rules().insertIssueRule();
db.issues().insertIssue(rule, project1, project1, issue -> issue.setAuthorLogin(leia));
@@ -137,18 +133,15 @@ public class AuthorsActionTest {
userSession.logIn();
assertThat(ws.newRequest()
- .setParam("organization", organization.getKey())
.setParam("project", project1.getKey())
.executeProtobuf(AuthorsResponse.class).getAuthorsList())
.containsExactlyInAnyOrder(leia);
assertThat(ws.newRequest()
- .setParam("organization", organization.getKey())
.setParam("project", project1.getKey())
.setParam(TEXT_QUERY, "eia")
.executeProtobuf(AuthorsResponse.class).getAuthorsList())
.containsExactlyInAnyOrder(leia);
assertThat(ws.newRequest()
- .setParam("organization", organization.getKey())
.setParam("project", project1.getKey())
.setParam(TEXT_QUERY, "luke")
.executeProtobuf(AuthorsResponse.class).getAuthorsList())
@@ -160,9 +153,8 @@ public class AuthorsActionTest {
@Test
public void search_authors_by_portfolio() {
String leia = "leia.organa";
- OrganizationDto organization = db.getDefaultOrganization();
- ComponentDto portfolio = db.components().insertPrivatePortfolio(organization);
- ComponentDto project = db.components().insertPrivateProject(organization);
+ ComponentDto portfolio = db.components().insertPrivatePortfolio();
+ ComponentDto project = db.components().insertPrivateProject();
db.components().insertComponent(newProjectCopy(project, portfolio));
permissionIndexer.allowOnlyAnyone(project);
RuleDefinitionDto rule = db.rules().insertIssueRule();
@@ -180,9 +172,8 @@ public class AuthorsActionTest {
@Test
public void search_authors_by_application() {
String leia = "leia.organa";
- OrganizationDto defaultOrganization = db.getDefaultOrganization();
- ComponentDto application = db.components().insertPrivateApplication(defaultOrganization);
- ComponentDto project = db.components().insertPrivateProject(defaultOrganization);
+ ComponentDto application = db.components().insertPrivateApplication();
+ ComponentDto project = db.components().insertPrivateProject();
db.components().insertComponent(newProjectCopy(project, application));
permissionIndexer.allowOnlyAnyone(project);
RuleDefinitionDto rule = db.rules().insertIssueRule();
@@ -265,14 +256,12 @@ public class AuthorsActionTest {
@Test
public void fail_when_project_does_not_exist() {
- OrganizationDto organization = db.organizations().insert();
userSession.logIn();
expectedException.expect(NotFoundException.class);
expectedException.expectMessage("Component key 'unknown' not found");
ws.newRequest()
- .setParam("organization", organization.getKey())
.setParam("project", "unknown")
.execute();
}
@@ -289,6 +278,7 @@ public class AuthorsActionTest {
String result = ws.newRequest().execute().getInput();
+ assertThat(ws.getDef().responseExampleAsString()).isNotNull();
assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString());
}
@@ -307,7 +297,6 @@ public class AuthorsActionTest {
.containsExactlyInAnyOrder(
tuple("q", false, false),
tuple("ps", false, false),
- tuple("organization", false, true),
tuple("project", false, false));
assertThat(definition.param("ps"))
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
index 12ad5307efb..7c7cb3393d3 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
@@ -60,7 +60,6 @@ import org.sonar.server.issue.notification.IssuesChangesNotificationSerializer;
import org.sonar.server.issue.workflow.FunctionExecutor;
import org.sonar.server.issue.workflow.IssueWorkflow;
import org.sonar.server.notification.NotificationManager;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.rule.DefaultRuleFinder;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
@@ -78,7 +77,6 @@ import static org.assertj.core.api.Assertions.tuple;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
-import static org.mockito.Mockito.verifyZeroInteractions;
import static org.sonar.api.issue.DefaultTransitions.RESOLVE_AS_REVIEWED;
import static org.sonar.api.issue.Issue.RESOLUTION_FIXED;
import static org.sonar.api.issue.Issue.STATUS_CLOSED;
@@ -270,7 +268,6 @@ public class BulkChangeActionTest {
RuleDefinitionDto rule = db.rules().insertIssueRule();
UserDto oldAssignee = db.users().insertUser();
UserDto userToAssign = db.users().insertUser();
- db.organizations().addMember(db.getDefaultOrganization(), userToAssign);
IssueDto issue1 = db.issues().insertIssue(rule, project, file,
i -> i.setAssigneeUuid(oldAssignee.getUuid()).setType(BUG).setSeverity(MINOR).setStatus(STATUS_OPEN).setResolution(null));
IssueDto issue2 = db.issues().insertIssue(rule, project, file,
@@ -408,7 +405,7 @@ public class BulkChangeActionTest {
.build());
checkResponse(response, 1, 1, 0, 0);
- verifyZeroInteractions(notificationManager);
+ verifyNoInteractions(notificationManager);
verifyPostProcessorCalled(fileOnBranch);
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
index b645d470a8d..99e7738f7cc 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
@@ -32,7 +32,6 @@ import org.sonar.core.issue.FieldDiffs;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.issue.IssueDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.db.rule.RuleDto;
import org.sonar.db.user.UserDto;
@@ -106,8 +105,7 @@ public class ChangelogActionTest {
@Test
public void changelog_of_file_move_contains_file_names() {
RuleDto rule = db.rules().insertRule(newRuleDto());
- OrganizationDto org = db.organizations().insert();
- ComponentDto project = db.components().insertPrivateProject(org);
+ ComponentDto project = db.components().insertPrivateProject();
ComponentDto file1 = db.components().insertComponent(newFileDto(project));
ComponentDto file2 = db.components().insertComponent(newFileDto(project));
IssueDto issueDto = db.issues().insertIssue(newDto(rule, file2, project));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ComponentTagsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ComponentTagsActionTest.java
index 14daa1324f9..b9ee5c37f82 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ComponentTagsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ComponentTagsActionTest.java
@@ -50,30 +50,29 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
-import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
import static org.sonar.test.JsonAssert.assertJson;
public class ComponentTagsActionTest {
- private static String[] ISSUE_RULE_TYPES = Arrays.stream(RuleType.values())
+ private static final String[] ISSUE_RULE_TYPES = Arrays.stream(RuleType.values())
.filter(t -> t != SECURITY_HOTSPOT)
.map(Enum::name)
.toArray(String[]::new);
- private IssueIndex service = mock(IssueIndex.class);
- private IssueQueryFactory issueQueryFactory = mock(IssueQueryFactory.class, Mockito.RETURNS_DEEP_STUBS);
- private IssueIndexSyncProgressChecker issueIndexSyncProgressChecker = mock(IssueIndexSyncProgressChecker.class);
- private DbClient dbClient = mock(DbClient.class);
- private ComponentDao componentDao = mock(ComponentDao.class);
- private ComponentTagsAction underTest = new ComponentTagsAction(service, issueIndexSyncProgressChecker,
+ private final IssueIndex service = mock(IssueIndex.class);
+ private final IssueQueryFactory issueQueryFactory = mock(IssueQueryFactory.class, Mockito.RETURNS_DEEP_STUBS);
+ private final IssueIndexSyncProgressChecker issueIndexSyncProgressChecker = mock(IssueIndexSyncProgressChecker.class);
+ private final DbClient dbClient = mock(DbClient.class);
+ private final ComponentDao componentDao = mock(ComponentDao.class);
+ private final ComponentTagsAction underTest = new ComponentTagsAction(service, issueIndexSyncProgressChecker,
issueQueryFactory, dbClient);
- private WsActionTester tester = new WsActionTester(underTest);
+ private final WsActionTester tester = new WsActionTester(underTest);
@Before
public void before() {
when(dbClient.componentDao()).thenReturn(componentDao);
when(componentDao.selectByUuid(any(), any())).thenAnswer((Answer<Optional<ComponentDto>>) invocation -> {
Object[] args = invocation.getArguments();
- return Optional.of(ComponentTesting.newPrivateProjectDto(newOrganizationDto(), (String) args[1]));
+ return Optional.of(ComponentTesting.newPrivateProjectDto((String) args[1]));
});
when(componentDao.selectByUuid(any(), eq("not-exists")))
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java
index 3fb4f2dd57f..51dd793b3cc 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java
@@ -48,8 +48,6 @@ import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Chan
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange;
import org.sonar.server.issue.notification.IssuesChangesNotificationSerializer;
import org.sonar.server.notification.NotificationManager;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.rule.DefaultRuleFinder;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java
index a64081a1a3c..ad91674f16a 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java
@@ -34,7 +34,6 @@ import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.issue.IssueDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.server.es.EsTester;
import org.sonar.server.issue.AvatarResolverImpl;
@@ -131,12 +130,10 @@ public class SearchActionComponentsTest {
@Test
public void issues_on_different_projects() {
RuleDefinitionDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
- OrganizationDto organization1 = db.organizations().insert();
- ComponentDto project = db.components().insertPublicProject(organization1);
+ ComponentDto project = db.components().insertPublicProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
IssueDto issue1 = db.issues().insertIssue(rule, project, file);
- OrganizationDto organization2 = db.organizations().insert();
- ComponentDto project2 = db.components().insertPublicProject(organization2);
+ ComponentDto project2 = db.components().insertPublicProject();
ComponentDto file2 = db.components().insertComponent(newFileDto(project2));
IssueDto issue2 = db.issues().insertIssue(rule, project2, file2);
allowAnyoneOnProjects(project, project2);
@@ -372,7 +369,7 @@ public class SearchActionComponentsTest {
public void search_by_view_uuid() {
ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey("PK1"));
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
- ComponentDto view = db.components().insertComponent(newView(db.getDefaultOrganization(), "V1").setDbKey("MyView"));
+ ComponentDto view = db.components().insertComponent(newView("V1").setDbKey("MyView"));
db.components().insertComponent(newProjectCopy(project, view));
RuleDefinitionDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
@@ -391,7 +388,7 @@ public class SearchActionComponentsTest {
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
RuleDefinitionDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
- ComponentDto view = db.components().insertComponent(newView(db.getDefaultOrganization(), "V1").setDbKey("MyView"));
+ ComponentDto view = db.components().insertComponent(newView("V1").setDbKey("MyView"));
ComponentDto subView = db.components().insertComponent(newSubView(view, "SV1", "MySubView"));
db.components().insertComponent(newProjectCopy(project, subView));
allowAnyoneOnProjects(project, view, subView);
@@ -409,7 +406,7 @@ public class SearchActionComponentsTest {
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setDbKey("FK1"));
RuleDefinitionDto rule = db.rules().insertIssueRule(r -> r.setRuleKey(RuleKey.of("xoo", "x1")));
db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
- ComponentDto view = db.components().insertComponent(newView(db.getDefaultOrganization(), "V1").setDbKey("MyView"));
+ ComponentDto view = db.components().insertComponent(newView("V1").setDbKey("MyView"));
ComponentDto subView = db.components().insertComponent(newSubView(view, "SV1", "MySubView"));
db.components().insertComponent(newProjectCopy(project, subView));
// User has no permission on the view, no issue will be returned
@@ -424,7 +421,7 @@ public class SearchActionComponentsTest {
@Test
public void search_by_application_key() {
- ComponentDto application = db.components().insertPrivateApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPrivateApplication();
ComponentDto project1 = db.components().insertPrivateProject();
ComponentDto project2 = db.components().insertPrivateProject();
db.components().insertComponents(newProjectCopy(project1, application));
@@ -497,7 +494,7 @@ public class SearchActionComponentsTest {
@Test
public void ignore_application_without_browse_permission() {
ComponentDto project = db.components().insertPublicProject();
- ComponentDto application = db.components().insertPublicApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPublicApplication();
db.components().insertComponents(newProjectCopy("PC1", project, application));
RuleDefinitionDto rule = db.rules().insertIssueRule();
db.issues().insertIssue(rule, project, project);
@@ -514,7 +511,7 @@ public class SearchActionComponentsTest {
@Test
public void search_application_without_projects() {
ComponentDto project = db.components().insertPublicProject();
- ComponentDto application = db.components().insertPublicApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPublicApplication();
RuleDefinitionDto rule = db.rules().insertIssueRule();
db.issues().insertIssue(rule, project, project);
allowAnyoneOnProjects(project, application);
@@ -531,7 +528,7 @@ public class SearchActionComponentsTest {
public void search_by_application_and_by_leak() {
Date now = new Date();
RuleDefinitionDto rule = db.rules().insertIssueRule();
- ComponentDto application = db.components().insertPublicApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPublicApplication();
// Project 1
ComponentDto project1 = db.components().insertPublicProject();
db.components().insertSnapshot(project1, s -> s.setPeriodDate(addDays(now, -14).getTime()));
@@ -562,7 +559,7 @@ public class SearchActionComponentsTest {
public void search_by_application_and_project() {
ComponentDto project1 = db.components().insertPublicProject();
ComponentDto project2 = db.components().insertPublicProject();
- ComponentDto application = db.components().insertPublicApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPublicApplication();
db.components().insertComponents(newProjectCopy("PC1", project1, application));
db.components().insertComponents(newProjectCopy("PC2", project2, application));
RuleDefinitionDto rule = db.rules().insertIssueRule();
@@ -585,7 +582,7 @@ public class SearchActionComponentsTest {
public void search_by_application_and_project_and_leak() {
Date now = new Date();
RuleDefinitionDto rule = db.rules().insertIssueRule();
- ComponentDto application = db.components().insertPublicApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPublicApplication();
// Project 1
ComponentDto project1 = db.components().insertPublicProject();
db.components().insertSnapshot(project1, s -> s.setPeriodDate(addDays(now, -14).getTime()));
@@ -617,7 +614,7 @@ public class SearchActionComponentsTest {
public void search_by_application_and_by_leak_when_one_project_has_no_leak() {
Date now = new Date();
RuleDefinitionDto rule = db.rules().insertIssueRule();
- ComponentDto application = db.components().insertPublicApplication(db.getDefaultOrganization());
+ ComponentDto application = db.components().insertPublicApplication();
// Project 1
ComponentDto project1 = db.components().insertPublicProject();
db.components().insertSnapshot(project1, s -> s.setPeriodDate(addDays(now, -14).getTime()));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionFacetsTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionFacetsTest.java
index f47dc90d403..449d951543c 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionFacetsTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionFacetsTest.java
@@ -35,7 +35,6 @@ import org.sonar.api.utils.Durations;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.db.user.UserDto;
import org.sonar.server.es.EsTester;
@@ -69,7 +68,6 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_K
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_UUIDS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_MODULE_UUIDS;
-import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PROJECTS;
public class SearchActionFacetsTest {
@@ -195,12 +193,9 @@ public class SearchActionFacetsTest {
@Test
public void projects_facet_is_sticky() {
- OrganizationDto organization1 = db.organizations().insert();
- OrganizationDto organization2 = db.organizations().insert();
- OrganizationDto organization3 = db.organizations().insert();
- ComponentDto project1 = db.components().insertPublicProject(organization1);
- ComponentDto project2 = db.components().insertPublicProject(organization2);
- ComponentDto project3 = db.components().insertPublicProject(organization3);
+ ComponentDto project1 = db.components().insertPublicProject();
+ ComponentDto project2 = db.components().insertPublicProject();
+ ComponentDto project3 = db.components().insertPublicProject();
ComponentDto file1 = db.components().insertComponent(newFileDto(project1));
ComponentDto file2 = db.components().insertComponent(newFileDto(project2));
ComponentDto file3 = db.components().insertComponent(newFileDto(project3));
@@ -308,8 +303,7 @@ public class SearchActionFacetsTest {
@Test
public void display_files_facet_with_project() {
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertPublicProject(organization);
+ ComponentDto project = db.components().insertPublicProject();
ComponentDto file1 = db.components().insertComponent(newFileDto(project));
ComponentDto file2 = db.components().insertComponent(newFileDto(project));
ComponentDto file3 = db.components().insertComponent(newFileDto(project));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
index 8968fb75308..8650ea404b7 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
@@ -51,7 +51,6 @@ import org.sonar.db.component.ComponentTesting;
import org.sonar.db.component.SnapshotDto;
import org.sonar.db.issue.IssueChangeDto;
import org.sonar.db.issue.IssueDto;
-import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.permission.GroupPermissionDto;
import org.sonar.db.protobuf.DbCommons;
import org.sonar.db.protobuf.DbIssues;
@@ -127,21 +126,21 @@ public class SearchActionTest {
@Rule
public ExpectedException expectedException = none();
- private DbClient dbClient = db.getDbClient();
- private DbSession session = db.getSession();
- private IssueIndex issueIndex = new IssueIndex(es.client(), System2.INSTANCE, userSession, new WebAuthorizationTypeSupport(userSession));
- private IssueIndexer issueIndexer = new IssueIndexer(es.client(), dbClient, new IssueIteratorFactory(dbClient), null);
- private IssueQueryFactory issueQueryFactory = new IssueQueryFactory(dbClient, Clock.systemUTC(), userSession);
- private IssueFieldsSetter issueFieldsSetter = new IssueFieldsSetter();
- private IssueWorkflow issueWorkflow = new IssueWorkflow(new FunctionExecutor(issueFieldsSetter), issueFieldsSetter);
- private SearchResponseLoader searchResponseLoader = new SearchResponseLoader(userSession, dbClient, new TransitionService(userSession, issueWorkflow));
- private Languages languages = new Languages();
- private UserResponseFormatter userFormatter = new UserResponseFormatter(new AvatarResolverImpl());
- private SearchResponseFormat searchResponseFormat = new SearchResponseFormat(new Durations(), languages, new TextRangeResponseFormatter(), userFormatter);
- private IssueIndexSyncProgressChecker issueIndexSyncProgressChecker = new IssueIndexSyncProgressChecker(dbClient);
- private WsActionTester ws = new WsActionTester(
+ private final DbClient dbClient = db.getDbClient();
+ private final DbSession session = db.getSession();
+ private final IssueIndex issueIndex = new IssueIndex(es.client(), System2.INSTANCE, userSession, new WebAuthorizationTypeSupport(userSession));
+ private final IssueIndexer issueIndexer = new IssueIndexer(es.client(), dbClient, new IssueIteratorFactory(dbClient), null);
+ private final IssueQueryFactory issueQueryFactory = new IssueQueryFactory(dbClient, Clock.systemUTC(), userSession);
+ private final IssueFieldsSetter issueFieldsSetter = new IssueFieldsSetter();
+ private final IssueWorkflow issueWorkflow = new IssueWorkflow(new FunctionExecutor(issueFieldsSetter), issueFieldsSetter);
+ private final SearchResponseLoader searchResponseLoader = new SearchResponseLoader(userSession, dbClient, new TransitionService(userSession, issueWorkflow));
+ private final Languages languages = new Languages();
+ private final UserResponseFormatter userFormatter = new UserResponseFormatter(new AvatarResolverImpl());
+ private final SearchResponseFormat searchResponseFormat = new SearchResponseFormat(new Durations(), languages, new TextRangeResponseFormatter(), userFormatter);
+ private final IssueIndexSyncProgressChecker issueIndexSyncProgressChecker = new IssueIndexSyncProgressChecker(dbClient);
+ private final WsActionTester ws = new WsActionTester(
new SearchAction(userSession, issueIndex, issueQueryFactory, issueIndexSyncProgressChecker, searchResponseLoader, searchResponseFormat, System2.INSTANCE, dbClient));
- private PermissionIndexer permissionIndexer = new PermissionIndexer(dbClient, es.client(), issueIndexer);
+ private final PermissionIndexer permissionIndexer = new PermissionIndexer(dbClient, es.client(), issueIndexer);
@Before
public void setUp() {
@@ -150,11 +149,9 @@ public class SearchActionTest {
@Test
public void response_contains_all_fields_except_additional_fields() {
- OrganizationDto organization = db.organizations().insert();
UserDto user = db.users().insertUser();
- db.organizations().addMember(organization, user);
userSession.logIn(user);
- ComponentDto project = db.components().insertPublicProject(organization);
+ ComponentDto project = db.components().insertPublicProject();
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project));
UserDto simon = db.users().insertUser();
@@ -180,18 +177,17 @@ public class SearchActionTest {
assertThat(response.getIssuesList())
.extracting(
- Issue::getOrganization, Issue::getKey, Issue::getRule, Issue::getSeverity, Issue::getComponent, Issue::getResolution, Issue::getStatus, Issue::getMessage, Issue::getEffort,
+ Issue::getKey, Issue::getRule, Issue::getSeverity, Issue::getComponent, Issue::getResolution, Issue::getStatus, Issue::getMessage, Issue::getEffort,
Issue::getAssignee, Issue::getAuthor, Issue::getLine, Issue::getHash, Issue::getTagsList, Issue::getCreationDate, Issue::getUpdateDate)
.containsExactlyInAnyOrder(
- tuple(organization.getKey(), issue.getKey(), rule.getKey().toString(), Severity.MAJOR, file.getKey(), RESOLUTION_FIXED, STATUS_RESOLVED, "the message", "10min",
+ tuple(issue.getKey(), rule.getKey().toString(), Severity.MAJOR, file.getKey(), RESOLUTION_FIXED, STATUS_RESOLVED, "the message", "10min",
simon.getLogin(), "John", 42, "a227e508d6646b55a086ee11d63b21e9", asList("bug", "owasp"), formatDateTime(issue.getIssueCreationDate()),
formatDateTime(issue.getIssueUpdateDate())));
}
@Test
public void issue_on_external_rule() {
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertPublicProject(organization);
+ ComponentDto project = db.components().insertPublicProject();
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule = db.rules().insertIssueRule(RuleTesting.EXTERNAL_XOO, r -> r.setIsExternal(true).setLanguage("xoo"));
@@ -207,26 +203,6 @@ public class SearchActionTest {
}
@Test
- public void hide_author_if_not_member_of_organization() {
- UserDto user = db.users().insertUser();
- userSession.logIn(user);
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertPublicProject(organization);
- indexPermissions();
- ComponentDto file = db.components().insertComponent(newFileDto(project));
- RuleDefinitionDto rule = newIssueRule().getDefinition();
- IssueDto issue = db.issues().insertIssue(rule, project, file, i -> i.setAuthorLogin("John"));
- indexIssues();
-
- SearchWsResponse response = ws.newRequest()
- .executeProtobuf(SearchWsResponse.class);
-
- assertThat(response.getIssuesList())
- .extracting(Issue::getKey, Issue::hasAuthor)
- .containsExactlyInAnyOrder(tuple(issue.getKey(), false));
- }
-
- @Test
public void issue_with_cross_file_locations() {
ComponentDto project = db.components().insertPublicProject();
indexPermissions();
@@ -378,8 +354,8 @@ public class SearchActionTest {
public void load_additional_fields_with_issue_admin_permission() {
UserDto simon = db.users().insertUser(u -> u.setLogin("simon").setName("Simon").setEmail("simon@email.com"));
UserDto fabrice = db.users().insertUser(u -> u.setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
- OrganizationDto organization = db.organizations().insert(o -> o.setKey("my-org-1"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY").setLanguage("java"));
+
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY").setLanguage("java"));
grantPermissionToAnyone(project, ISSUE_ADMIN);
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY").setLanguage("js"));
@@ -403,8 +379,7 @@ public class SearchActionTest {
@Test
public void search_by_rule_key() {
RuleDto rule = newIssueRule();
- OrganizationDto organization = db.organizations().insert(o -> o.setKey("my-org-1"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY").setLanguage("java"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY").setLanguage("java"));
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY").setLanguage("java"));
db.issues().insertIssue(rule.getDefinition(), project, file);
@@ -425,8 +400,7 @@ public class SearchActionTest {
@Test
public void issue_on_removed_file() {
RuleDto rule = newIssueRule();
- OrganizationDto organization = db.organizations().insert(o -> o.setKey("my-org-2"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto removedFile = db.components().insertComponent(newFileDto(project, null).setUuid("REMOVED_FILE_ID")
.setDbKey("REMOVED_FILE_KEY")
@@ -451,8 +425,7 @@ public class SearchActionTest {
@Test
public void apply_paging_with_one_component() {
RuleDto rule = newIssueRule();
- OrganizationDto organization = db.organizations().insert(o -> o.setKey("my-org-2"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
for (int i = 0; i < SearchOptions.MAX_PAGE_SIZE + 1; i++) {
@@ -468,8 +441,7 @@ public class SearchActionTest {
@Test
public void components_contains_sub_projects() {
- OrganizationDto organization = db.organizations().insert(o -> o.setKey("my-org-1"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("ProjectHavingModule"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("ProjectHavingModule"));
indexPermissions();
ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project).setDbKey("ModuleHavingFile"));
ComponentDto file = db.components().insertComponent(newFileDto(module, null, "BCDE").setDbKey("FileLinkedToModule"));
@@ -486,8 +458,7 @@ public class SearchActionTest {
public void filter_by_assigned_to_me() {
UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
RuleDto rule = newIssueRule();
@@ -533,8 +504,7 @@ public class SearchActionTest {
public void filter_by_leak_period() {
UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
SnapshotDto snapshotDto = db.components().insertSnapshot(project, s -> s.setLast(true).setPeriodDate(parseDateTime("2014-09-05T00:00:00+0100").getTime()));
indexPermissions();
@@ -573,8 +543,7 @@ public class SearchActionTest {
public void filter_by_leak_period_without_a_period() {
UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
SnapshotDto snapshotDto = db.components().insertSnapshot(project);
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
@@ -612,8 +581,7 @@ public class SearchActionTest {
public void filter_by_leak_period_has_no_effect_on_prs() {
UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertPublicProject(organization, c -> c.setUuid("PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertPublicProject(c -> c.setUuid("PROJECT_ID").setDbKey("PROJECT_KEY"));
ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.PULL_REQUEST).setKey("pr"));
SnapshotDto snapshotDto = db.components().insertSnapshot(pr);
indexPermissions();
@@ -653,8 +621,7 @@ public class SearchActionTest {
public void return_empty_when_login_is_unknown() {
UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
RuleDto rule = newIssueRule();
@@ -703,8 +670,7 @@ public class SearchActionTest {
userSession.logIn(poy);
UserDto alice = db.users().insertUser(u -> u.setLogin("alice").setName("Alice").setEmail("alice@email.com"));
UserDto john = db.users().insertUser(u -> u.setLogin("john").setName("John").setEmail("john@email.com"));
- OrganizationDto organization = db.organizations().insert(o -> o.setKey("my-org-1"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
RuleDto rule = newIssueRule();
@@ -766,8 +732,7 @@ public class SearchActionTest {
@Test
public void filter_by_test_scope() {
- OrganizationDto organization = db.organizations().insert(p -> p.setUuid("org-1").setKey("org-1"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto mainCodeFile = db.components().insertComponent(
newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
@@ -808,8 +773,7 @@ public class SearchActionTest {
@Test
public void filter_by_main_scope() {
- OrganizationDto organization = db.organizations().insert(p -> p.setUuid("org-1").setKey("org-1"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto mainCodeFile = db.components().insertComponent(
newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
@@ -853,8 +817,7 @@ public class SearchActionTest {
@Test
public void filter_by_scope_always_returns_all_scope_facet_values() {
- OrganizationDto organization = db.organizations().insert(p -> p.setUuid("org-1").setKey("org-1"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto mainCodeFile = db.components().insertComponent(
newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
@@ -922,8 +885,7 @@ public class SearchActionTest {
@Test
public void sort_by_updated_at() {
RuleDto rule = newIssueRule();
- OrganizationDto organization = db.organizations().insert(o -> o.setKey("my-org-2"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
dbClient.issueDao().insert(session, newDto(rule, file, project)
@@ -1249,8 +1211,7 @@ public class SearchActionTest {
@Test
public void paging() {
RuleDto rule = newIssueRule();
- OrganizationDto organization = db.organizations().insert(o -> o.setKey("my-org-1"));
- ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto(organization, "PROJECT_ID").setDbKey("PROJECT_KEY"));
+ ComponentDto project = db.components().insertComponent(ComponentTesting.newPublicProjectDto("PROJECT_ID").setDbKey("PROJECT_KEY"));
indexPermissions();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setDbKey("FILE_KEY"));
for (int i = 0; i < 12; i++) {
@@ -1327,16 +1288,10 @@ public class SearchActionTest {
assertThat(def.responseExampleAsString()).isNotEmpty();
assertThat(def.params()).extracting("key").containsExactlyInAnyOrder(
- "additionalFields", "asc", "assigned", "assignees", "authors", "author", "componentKeys", "branch",
- "pullRequest", "organization",
- "createdAfter", "createdAt", "createdBefore", "createdInLast", "directories", "facetMode", "facets", "files", "issues", "scopes", "languages", "moduleUuids",
- "onComponentOnly",
- "p", "projects", "ps", "resolutions", "resolved", "rules", "s", "severities", "sinceLeakPeriod",
- "statuses", "tags", "types", "owaspTop10", "sansTop25", "cwe", "sonarsourceSecurity", "timeZone");
-
- assertThat(def.param("organization"))
- .matches(WebService.Param::isInternal)
- .matches(p -> p.since().equals("6.4"));
+ "additionalFields", "asc", "assigned", "assignees", "authors", "author", "componentKeys", "branch", "pullRequest", "createdAfter", "createdAt",
+ "createdBefore", "createdInLast", "directories", "facetMode", "facets", "files", "issues", "scopes", "languages", "moduleUuids", "onComponentOnly",
+ "p", "projects", "ps", "resolutions", "resolved", "rules", "s", "severities", "sinceLeakPeriod", "statuses", "tags", "types", "owaspTop10", "sansTop25",
+ "cwe", "sonarsourceSecurity", "timeZone");
WebService.Param branch = def.param(PARAM_BRANCH);
assertThat(branch.isInternal()).isFalse();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java
index a635cb52e93..6a25535c0f0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java
@@ -53,8 +53,6 @@ import org.sonar.server.issue.index.IssueIndexer;
import org.sonar.server.issue.index.IssueIteratorFactory;
import org.sonar.server.issue.notification.IssuesChangesNotificationSerializer;
import org.sonar.server.notification.NotificationManager;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.rule.DefaultRuleFinder;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
@@ -95,7 +93,8 @@ public class SetTagsActionTest {
private WsActionTester ws = new WsActionTester(new SetTagsAction(userSession, dbClient, new IssueFinder(dbClient, userSession), new IssueFieldsSetter(),
new IssueUpdater(dbClient,
new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient), issueIndexer, new SequenceUuidFactory()),
- mock(NotificationManager.class), issueChangePostProcessor, issuesChangesSerializer), responseWriter));
+ mock(NotificationManager.class), issueChangePostProcessor, issuesChangesSerializer),
+ responseWriter));
@Test
public void set_tags() {
@@ -212,7 +211,7 @@ public class SetTagsActionTest {
@Test
public void fail_when_security_hotspot() {
RuleDefinitionDto rule = db.rules().insertHotspotRule();
- ComponentDto project = db.components().insertPublicProject(newPublicProjectDto(db.getDefaultOrganization()));
+ ComponentDto project = db.components().insertPublicProject(newPublicProjectDto());
ComponentDto file = db.components().insertComponent(newFileDto(project));
IssueDto issueDto = db.issues().insertHotspot(rule, project, file);
logIn(issueDto);
@@ -245,7 +244,7 @@ public class SetTagsActionTest {
@SafeVarargs
private final IssueDto insertIssueForPublicProject(Consumer<IssueDto>... consumers) {
RuleDefinitionDto rule = db.rules().insertIssueRule();
- ComponentDto project = db.components().insertPublicProject(newPublicProjectDto(db.getDefaultOrganization()));
+ ComponentDto project = db.components().insertPublicProject(newPublicProjectDto());
ComponentDto file = db.components().insertComponent(newFileDto(project));
return db.issues().insertIssue(rule, project, file, consumers);
}
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/assigned_to_me_facet_sticky.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/assigned_to_me_facet_sticky.json
index ca29e4e065e..294b82ab004 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/assigned_to_me_facet_sticky.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/assigned_to_me_facet_sticky.json
@@ -1,7 +1,6 @@
{
"issues": [
{
- "organization": "my-org-2",
"key": "7b112bd4-b650-4037-80bc-82fd47d4eac2",
"component": "FILE_KEY",
"rule": "xoo:x1",
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/author_is_hidden.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/author_is_hidden.json
index 357e05cad31..2aeea8c9450 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/author_is_hidden.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/author_is_hidden.json
@@ -1,7 +1,6 @@
{
"issues": [
{
- "organization": "my-org-2",
"key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
"rule": "external_xoo:x1",
"severity": "MAJOR",
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/components_contains_sub_projects.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/components_contains_sub_projects.json
index ff13b0b2e6b..5ff9016c910 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/components_contains_sub_projects.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/components_contains_sub_projects.json
@@ -1,15 +1,12 @@
{
"components": [
{
- "organization": "my-org-1",
"key": "FileLinkedToModule"
},
{
- "organization": "my-org-1",
"key": "ModuleHavingFile"
},
{
- "organization": "my-org-1",
"key": "ProjectHavingModule"
}
]
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_facets.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_facets.json
index 38fd2f2b973..c4e55063d39 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_facets.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_facets.json
@@ -1,7 +1,6 @@
{
"issues": [
{
- "organization": "my-org-1",
"key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
"component": "FILE_KEY",
"rule": "xoo:x1",
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_facets_effort.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_facets_effort.json
index edf7821dd0c..9b3fd00c836 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_facets_effort.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_facets_effort.json
@@ -2,7 +2,6 @@
"effortTotal": 10,
"issues": [
{
- "organization": "my-org-2",
"key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
"component": "FILE_KEY",
"project": "PROJECT_KEY",
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_zero_facets.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_zero_facets.json
index 5bbf619ab43..35810d03c73 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_zero_facets.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/display_zero_facets.json
@@ -1,7 +1,6 @@
{
"issues": [
{
- "organization": "my-org-1",
"key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
"component": "FILE_KEY",
"project": "PROJECT_KEY",
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_main_scope.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_main_scope.json
index 7fb92028da5..d40d5cadcf1 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_main_scope.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_main_scope.json
@@ -20,7 +20,6 @@
"status": "OPEN",
"effort": "10min",
"debt": "10min",
- "organization": "org-1",
"scope": "MAIN"
},
{
@@ -33,13 +32,11 @@
"status": "OPEN",
"effort": "10min",
"debt": "10min",
- "organization": "org-1",
"scope": "MAIN"
}
],
"components": [
{
- "organization": "org-1",
"key": "FILE_KEY",
"uuid": "FILE_ID",
"enabled": true,
@@ -49,7 +46,6 @@
"path": "null/NAME_FILE_ID"
},
{
- "organization": "org-1",
"key": "PROJECT_KEY",
"uuid": "PROJECT_ID",
"enabled": true,
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_main_scope_2.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_main_scope_2.json
index 9105ecbffb7..1cb0ca26609 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_main_scope_2.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_main_scope_2.json
@@ -20,7 +20,6 @@
"status": "OPEN",
"effort": "10min",
"debt": "10min",
- "organization": "org-1",
"scope": "MAIN"
},
{
@@ -33,13 +32,11 @@
"status": "OPEN",
"effort": "10min",
"debt": "10min",
- "organization": "org-1",
"scope": "MAIN"
}
],
"components": [
{
- "organization": "org-1",
"key": "FILE_KEY",
"uuid": "FILE_ID",
"enabled": true,
@@ -49,7 +46,6 @@
"path": "null/NAME_FILE_ID"
},
{
- "organization": "org-1",
"key": "PROJECT_KEY",
"uuid": "PROJECT_ID",
"enabled": true,
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_test_scope.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_test_scope.json
index e2488d26a4f..3afa99ee9b9 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_test_scope.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/filter_by_test_scope.json
@@ -20,13 +20,11 @@
"status": "OPEN",
"effort": "10min",
"debt": "10min",
- "organization": "org-1",
"scope": "TEST"
}
],
"components": [
{
- "organization": "org-1",
"key": "ANOTHER_FILE_KEY",
"uuid": "ANOTHER_FILE_ID",
"enabled": true,
@@ -36,7 +34,6 @@
"path": "null/NAME_ANOTHER_FILE_ID"
},
{
- "organization": "org-1",
"key": "PROJECT_KEY",
"uuid": "PROJECT_ID",
"enabled": true,
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/issue_on_removed_file.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/issue_on_removed_file.json
index cb319e33928..19b781d83e0 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/issue_on_removed_file.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/issue_on_removed_file.json
@@ -1,7 +1,6 @@
{
"issues": [
{
- "organization": "my-org-2",
"key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
"component": "REMOVED_FILE_KEY",
"project": "PROJECT_KEY",
@@ -14,12 +13,10 @@
],
"components": [
{
- "organization": "my-org-2",
"key": "REMOVED_FILE_KEY",
"enabled" : false
},
{
- "organization": "my-org-2",
"key": "PROJECT_KEY",
"enabled" : true
}
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/load_additional_fields_with_issue_admin_permission.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/load_additional_fields_with_issue_admin_permission.json
index fa13177f78d..7cdbead55f2 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/load_additional_fields_with_issue_admin_permission.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/load_additional_fields_with_issue_admin_permission.json
@@ -1,7 +1,6 @@
{
"issues": [
{
- "organization": "my-org-1",
"key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
"assignee": "simon",
"actions": [
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/response_contains_all_fields_except_additional_fields.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/response_contains_all_fields_except_additional_fields.json
index b008f9bff74..26c33ae92d2 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/response_contains_all_fields_except_additional_fields.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/response_contains_all_fields_except_additional_fields.json
@@ -1,7 +1,6 @@
{
"issues": [
{
- "organization": "my-org-2",
"key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
"rule": "external_xoo:x1",
"severity": "MAJOR",
diff --git a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/result_for_rule_search.json b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/result_for_rule_search.json
index fc0bc4ef013..ae2fcf37687 100644
--- a/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/result_for_rule_search.json
+++ b/server/sonar-webserver-webapi/src/test/resources/org/sonar/server/issue/ws/SearchActionTest/result_for_rule_search.json
@@ -12,11 +12,9 @@
"component": "FILE_KEY",
"project": "PROJECT_KEY",
"flows": [],
- "status": "OPEN",
- "organization": "my-org-1"
+ "status": "OPEN"
}],
"components": [ {
- "organization": "my-org-1",
"key": "FILE_KEY",
"uuid": "FILE_ID",
"enabled": true,
@@ -26,7 +24,6 @@
"path": "null/NAME_FILE_ID"
},
{
- "organization": "my-org-1",
"key": "PROJECT_KEY",
"uuid": "PROJECT_ID",
"enabled": true,