private LineHashesWithKeyDtoHandler scrollLineHashes(String... uuids) { LineHashesWithKeyDtoHandler handler = new LineHashesWithKeyDtoHandler(); underTest.scrollLineHashes(dbSession, ImmutableSet.copyOf(uuids), handler); return handler; }
newFiles, newFileSourcesByUuid, scoreMatrix); try (DbSession dbSession = dbClient.openSession(false)) { dbClient.fileSourceDao().scrollLineHashes(dbSession, removedFilesIndexes.keySet(), rowHandler);
@Test public void scrollLineHashes_has_no_effect_if_no_uuids() { underTest.scrollLineHashes(dbSession, emptySet(), resultContext -> fail("handler should not be called")); }
@Test public void scrollLineHashes_handles_scrolling_more_than_1000_files() { OrganizationDto organization = dbTester.organizations().insert(); ComponentDto project = new Random().nextBoolean() ? dbTester.components().insertPrivateProject(organization) : dbTester.components().insertPublicProject(organization); List<ComponentDto> files = IntStream.range(0, 1001 + new Random().nextInt(5)) .mapToObj(i -> { ComponentDto file = dbTester.components().insertComponent(newFileDto(project)); dbTester.fileSources().insertFileSource(file); return file; }) .collect(Collectors.toList()); LineHashesWithKeyDtoHandler handler = new LineHashesWithKeyDtoHandler(); underTest.scrollLineHashes(dbSession, files.stream().map(ComponentDto::uuid).collect(Collectors.toSet()), handler); assertThat(handler.dtos).hasSize(files.size()); files.forEach(t -> assertThat(handler.getByUuid(t.uuid())).isPresent()); }
newFiles, newFileSourcesByKey, scoreMatrix); try (DbSession dbSession = dbClient.openSession(false)) { dbClient.fileSourceDao().scrollLineHashes(dbSession, removedFilesIndexes.keySet(), rowHandler);