public ProjectRepositories addFileDataToModule(String moduleKey, @Nullable String path, FileData fileData) { if (path == null || (fileData.hash() == null && fileData.revision() == null)) { return this; } SingleProjectRepository repository = repositoryPerModule.computeIfAbsent(moduleKey, k -> new SingleProjectRepository()); repository.addFileData(path, fileData); return this; }
@Before public void setUp() { repository = new SingleProjectRepository(); }
@Test public void use_new_file_structure_for_projects_without_submodules() { String projectKey = "org.codehaus.sonar:sonar"; ProjectRepositories projectRepositories = new SingleProjectRepository() .addFileData("src/main/java/SomeClass.java", new FileData("789456", "123456789")); when(projectDataLoader.load(any(ProjectDataQuery.class))).thenReturn(projectRepositories); WsProjectResponse wsProjectResponse = ws.newRequest() .setParam("key", projectKey) .setParam("profile", "Default") .executeProtobuf(WsProjectResponse.class); assertThat(wsProjectResponse.getFileDataByModuleAndPathMap()).isEmpty(); assertThat(wsProjectResponse.getFileDataByPathCount()).isEqualTo(1); assertThat(wsProjectResponse.getFileDataByPathMap().get("src/main/java/SomeClass.java")).isNotNull(); }
data = repository; } else { SingleProjectRepository repository = new SingleProjectRepository(); addFileData(repository, files); data = repository;
public ProjectRepositories addFileDataToModule(String moduleKey, @Nullable String path, FileData fileData) { if (path == null || (fileData.hash() == null && fileData.revision() == null)) { return this; } SingleProjectRepository repository = repositoryPerModule.computeIfAbsent(moduleKey, k -> new SingleProjectRepository()); repository.addFileData(path, fileData); return this; }