public static Set<SingleDeprecatedRuleKey> from(RulesDefinition.Rule rule) {
    rule.deprecatedRuleKeys();
    return rule.deprecatedRuleKeys().stream()
      .map(r -> new SingleDeprecatedRuleKey()
        .setNewRepositoryKey(rule.repository().key())
        .setNewRuleKey(rule.key())
        .setOldRepositoryKey(r.repository())
        .setOldRuleKey(r.rule()))
      .collect(Collectors.toSet());
  }
@Test
  public void test_creation_from_RulesDefinitionRule() {
    // Creation from RulesDefinition.Rule
    ImmutableSet<RuleKey> deprecatedRuleKeys = ImmutableSet.of(
      RuleKey.of(randomAlphanumeric(50), randomAlphanumeric(50)),
      RuleKey.of(randomAlphanumeric(50), randomAlphanumeric(50)),
      RuleKey.of(randomAlphanumeric(50), randomAlphanumeric(50)));

    RulesDefinition.Repository repository = mock(RulesDefinition.Repository.class);
    when(repository.key()).thenReturn(randomAlphanumeric(50));

    RulesDefinition.Rule rule = mock(RulesDefinition.Rule.class);
    when(rule.key()).thenReturn(randomAlphanumeric(50));
    when(rule.deprecatedRuleKeys()).thenReturn(deprecatedRuleKeys);
    when(rule.repository()).thenReturn(repository);

    Set<SingleDeprecatedRuleKey> singleDeprecatedRuleKeys = SingleDeprecatedRuleKey.from(rule);
    assertThat(singleDeprecatedRuleKeys).hasSize(deprecatedRuleKeys.size());
    assertThat(singleDeprecatedRuleKeys)
      .extracting(SingleDeprecatedRuleKey::getUuid, SingleDeprecatedRuleKey::getOldRepositoryKey, SingleDeprecatedRuleKey::getOldRuleKey,
        SingleDeprecatedRuleKey::getNewRepositoryKey, SingleDeprecatedRuleKey::getNewRuleKey, SingleDeprecatedRuleKey::getOldRuleKeyAsRuleKey)
      .containsExactlyInAnyOrder(
        deprecatedRuleKeys.stream().map(
          r -> tuple(null, r.repository(), r.rule(), rule.repository().key(), rule.key(), RuleKey.of(r.repository(), r.rule())))
          .toList().toArray(new Tuple[deprecatedRuleKeys.size()]));
  }