@Test public void scrollLineHashes_scrolls_hashes_of_specific_keys() { OrganizationDto organization = dbTester.organizations().insert(); ComponentDto project = new Random().nextBoolean() ? dbTester.components().insertPrivateProject(organization) : dbTester.components().insertPublicProject(organization); ComponentDto file1 = dbTester.components().insertComponent(newFileDto(project)); FileSourceDto fileSource1 = dbTester.fileSources().insertFileSource(file1); ComponentDto file2 = dbTester.components().insertComponent(newFileDto(project)); FileSourceDto fileSource2 = dbTester.fileSources().insertFileSource(file2); ComponentDto file3 = dbTester.components().insertComponent(newFileDto(project)); FileSourceDto fileSource3 = dbTester.fileSources().insertFileSource(file3); LineHashesWithKeyDtoHandler handler = scrollLineHashes(file1.uuid()); assertThat(handler.dtos).hasSize(1); verifyLinesHashes(handler, file1, fileSource1); handler = scrollLineHashes(file2.uuid()); assertThat(handler.dtos).hasSize(1); verifyLinesHashes(handler, file2, fileSource2); handler = scrollLineHashes(file2.uuid(), file1.uuid(), file3.uuid()); assertThat(handler.dtos).hasSize(3); verifyLinesHashes(handler, file1, fileSource1); verifyLinesHashes(handler, file2, fileSource2); verifyLinesHashes(handler, file3, fileSource3); }
@Test public void scrollLineHashes_does_not_scroll_hashes_of_component_without_path() { OrganizationDto organization = dbTester.organizations().insert(); ComponentDto project = new Random().nextBoolean() ? dbTester.components().insertPrivateProject(organization) : dbTester.components().insertPublicProject(organization); ComponentDto file1 = dbTester.components().insertComponent(newFileDto(project)); FileSourceDto fileSource1 = dbTester.fileSources().insertFileSource(file1); ComponentDto file2 = dbTester.components().insertComponent(newFileDto(project).setPath(null)); FileSourceDto fileSource2 = dbTester.fileSources().insertFileSource(file2); LineHashesWithKeyDtoHandler handler = scrollLineHashes(file2.uuid(), file1.uuid()); assertThat(handler.dtos).hasSize(1); verifyLinesHashes(handler, file1, fileSource1); }