public void appendIssuesToResponse(List<IssueDto> issueDtos, Map<String, RuleDto> ruleCache, OutputStream outputStream) {
    try {
      for (IssueDto issueDto : issueDtos) {
        RuleDto ruleDto = ruleCache.get(issueDto.getRuleUuid());
        AbstractMessageLite messageLite = protobufObjectGenerator.generateIssueMessage(issueDto, ruleDto);
        messageLite.writeDelimitedTo(outputStream);
      }
      outputStream.flush();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
@Test
  public void appendIssuesToResponse_outputStreamIsCalledAtLeastOnce() throws IOException {
    OutputStream outputStream = mock(OutputStream.class);
    IssueDto issueDto = new IssueDto();
    issueDto.setFilePath("filePath");
    issueDto.setKee("key");
    issueDto.setStatus("OPEN");
    issueDto.setRuleKey("repo", "rule");

    underTest.appendIssuesToResponse(List.of(issueDto), emptyMap(), outputStream);

    verify(outputStream, atLeastOnce()).write(any(byte[].class), anyInt(), anyInt());
  }