NewAdHocRule mapRule(ReportingDescriptor rule, String driverName, @Nullable Result.Level ruleSeverity, @Nullable Result.Level ruleSeverityForNewTaxonomy) {

    NewAdHocRule newAdHocRule = sensorContext.newAdHocRule()
      .severity(ResultMapper.toSonarQubeSeverity(ruleSeverity))
      .type(ResultMapper.DEFAULT_TYPE)
      .ruleId(rule.getId())
      .engineId(driverName)
      .cleanCodeAttribute(ResultMapper.DEFAULT_CLEAN_CODE_ATTRIBUTE)
      .addDefaultImpact(ResultMapper.DEFAULT_SOFTWARE_QUALITY, ResultMapper.toSonarQubeImpactSeverity(ruleSeverityForNewTaxonomy));

    if (rule.getShortDescription() != null && !StringUtils.isBlank(rule.getShortDescription().getText())) {
      newAdHocRule.name(rule.getShortDescription().getText());
    } else {
      newAdHocRule.name(join(":", driverName, rule.getId()));
    }

    if (rule.getFullDescription() != null && !StringUtils.isBlank(rule.getFullDescription().getText())) {
      newAdHocRule.description(rule.getFullDescription().getText());
    }

    return newAdHocRule;
  }
@Test
  public void mapRule_shouldCorrectlyMapToNewAdHocRule() {
    ReportingDescriptor rule = new ReportingDescriptor().withId(RULE_ID);
    NewAdHocRule expected = buildDefaultExpected();

    NewAdHocRule result = ruleMapper.mapRule(rule, DRIVER_NAME, WARNING, WARNING);
    assertThat(result).usingRecursiveComparison().isEqualTo(expected);
  }