### Question:
PipelineCodeHandler { @SuppressWarnings("PMD.AvoidCatchingGenericException") public List<DocWriteRequest> createPipelineCodeDocuments(final Pipeline pipeline, final PermissionsContainer permissions, final String revisionName, final String indexName, final List<String> pipelineFileIndexPaths) { return pipelineFileIndexPaths.stream() .map(path -> { log.debug("Fetching path {} for revisionName {}", path, revisionName); if (path.endsWith(FOLDER_INDICATOR)) { return getGitRepositoryEntries(pipeline, revisionName, path) .stream() .filter(content -> (content.getType().equals(GIT_ENTRY_TYPE))) .map(content -> createIndexRequest( pipeline, revisionName, indexName, content.getPath(), permissions)) .collect(Collectors.toList()); } return Collections.singletonList(createIndexRequest( pipeline, revisionName, indexName, path, permissions)); }) .flatMap(Collection::stream) .filter(Objects::nonNull) .collect(Collectors.toList()); } PipelineCodeHandler(final @Value("${sync.index.common.prefix}") String indexPrefix,
                               final @Value("${sync.pipeline-code.index.name}") String pipelineCodeIndexName,
                               final CloudPipelineAPIClient cloudPipelineAPIClient,
                               final ElasticIndexService indexService,
                               final @Value("${sync.pipeline-code.index.paths}") String pipelineFileIndexPaths,
                               final ObjectMapper objectMapper,
                               final PipelineLoader pipelineLoader,
                               final PipelineCodeMapper codeMapper,
                               final @Value("${sync.pipeline-code.default-branch}") String defaultBranchName,
                               final @Value("${sync.pipeline-code.max.bytes:10240}") Integer codeLimitBytes); List<DocWriteRequest> processGitEvents(final Long id,
                                                  final List<PipelineEvent> events); @SuppressWarnings("PMD.AvoidCatchingGenericException") List<DocWriteRequest> createPipelineCodeDocuments(final Pipeline pipeline,
                                                             final PermissionsContainer permissions,
                                                             final String revisionName,
                                                             final String indexName,
                                                             final List<String> pipelineFileIndexPaths);  }### Answer:
@Test void shouldCreatePipelineCodeDocumentsTest() { when(apiClient.loadRepositoryContents(anyLong(), anyString(), anyString())) .thenReturn(Collections.singletonList(gitRepositoryEntry)); when(apiClient.getTruncatedPipelineFile(anyLong(), anyString(), anyString(), anyInt())) .thenReturn(TEST_VALUE_BYTE); List<DocWriteRequest> docWriteRequests = pipelineCodeHandler.createPipelineCodeDocuments(pipeline, PERMISSIONS_CONTAINER, TEST_VERSION, INDEX_NAME, Collections.singletonList(FOLDER_INDEX_PATHS)); assertEquals(1, docWriteRequests.size()); DocWriteRequest request = docWriteRequests.get(0); assertAll("request", () -> assertEquals(INDEX_NAME, request.index()), () -> assertEquals(TEST_VERSION + "-" + FOLDER_INDEX_PATHS, request.id()), () -> assertEquals(DOC_TYPE, request.type())); }