public void direct_children_of_a_view() throws IOException {
ComponentDto view = newView("view-uuid");
SnapshotDto viewSnapshot = componentDb.insertViewAndSnapshot(view);
- ComponentDto project = newProjectDto("project-uuid-1");
+ ComponentDto project = newProjectDto("project-uuid-1").setName("project-name");
componentDb.insertProjectAndSnapshot(project);
componentDb.insertComponentAndSnapshot(newProjectCopy("project-uuid-1-copy", project, view), viewSnapshot);
- componentDb.insertComponentAndSnapshot(newSubView(view, "sub-view-uuid", "sub-view-key"), viewSnapshot);
+ componentDb.insertComponentAndSnapshot(newSubView(view, "sub-view-uuid", "sub-view-key").setName("sub-view-name"), viewSnapshot);
db.commit();
componentDb.indexProjects();
.setMediaType(MediaTypes.PROTOBUF)
.setParam(PARAM_STRATEGY, "children")
.setParam(PARAM_BASE_COMPONENT_ID, "view-uuid")
+ .setParam(Param.TEXT_QUERY, "name")
.execute().getInputStream();
WsComponents.TreeWsResponse response = WsComponents.TreeWsResponse.parseFrom(responseStream);
import static org.sonar.db.component.ComponentTesting.newDeveloper;
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.db.component.ComponentTesting.newModuleDto;
+import static org.sonar.db.component.ComponentTesting.newProjectCopy;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
+import static org.sonar.db.component.ComponentTesting.newSubView;
import static org.sonar.db.component.ComponentTesting.newView;
@Category(DbTests.class)
assertThat(result).extracting("uuid").containsExactly("file-1-uuid", "file-2-uuid", "module-1-uuid");
}
+ @Test
+ public void select_direct_children_of_a_view() {
+ ComponentDto view = newView("view-uuid");
+ SnapshotDto viewSnapshot = componentDb.insertViewAndSnapshot(view);
+ // one subview
+ ComponentDto subView = newSubView(view, "subview-uuid", "subview-key").setName("subview-name");
+ componentDb.insertComponentAndSnapshot(subView, viewSnapshot);
+ // one project and its copy linked to the view
+ ComponentDto project = newProjectDto("project-uuid").setName("project-name");
+ componentDb.insertProjectAndSnapshot(project);
+ componentDb.insertComponentAndSnapshot(newProjectCopy("project-copy-uuid", project, view), viewSnapshot);
+ componentDb.indexProjects();
+ ComponentTreeQuery dbQuery = newTreeQuery(viewSnapshot).setNameOrKeyQuery("name").build();
+
+ List<ComponentDtoWithSnapshotId> components = underTest.selectDirectChildren(dbSession, dbQuery);
+
+ assertThat(components).extracting("uuid").containsOnly("project-copy-uuid", "subview-uuid");
+ }
+
@Test
public void select_all_files_of_a_project_paginated_and_ordered() {
ComponentDto project = newProjectDto().setKey("project-key").setUuid("project-uuid");
.setPageSize(500)
.setBaseSnapshot(baseSnapshot)
.setSortFields(singletonList("name"))
- .setAsc(true)
- .setQualifiers(newArrayList(Qualifiers.FILE, Qualifiers.MODULE, Qualifiers.DIRECTORY, Qualifiers.PROJECT));
+ .setAsc(true);
}
}