public Ce.Task formatActivity(DbSession dbSession, CeActivityDto dto, @Nullable String scannerContext) {
    return formatActivity(dto, DtoCache.forActivityDtos(dbClient, dbSession, singletonList(dto)), scannerContext);
  }
@Test
  public void formatActivity_filterWarnings_andSetWarningsAndCount() {
    TestActivityDto dto = newActivity("UUID", "COMPONENT_UUID", CeActivityDto.Status.FAILED, null);
    CeTaskMessageDto warning1 = createCeTaskMessageDto(1998, MessageType.GENERIC);
    CeTaskMessageDto warning2 = createCeTaskMessageDto(1999, MessageType.GENERIC);

    List<CeTaskMessageDto> ceTaskMessageDtos = new ArrayList<>(dto.getCeTaskMessageDtos());
    ceTaskMessageDtos.add(warning1);
    ceTaskMessageDtos.add(warning2);
    dto.setCeTaskMessageDtos(ceTaskMessageDtos);

    Ce.Task wsTask = underTest.formatActivity(db.getSession(), dto, null);

    assertThat(wsTask.getWarningCount()).isEqualTo(2);
    assertThat(wsTask.getWarningsList()).hasSameElementsAs(getMessagesText(List.of(warning1, warning2)));
  }