@Override
  public Rule register(String ref, RuleKey ruleKey) {
    requireNonNull(ruleKey, "ruleKey can not be null");

    Rule rule = rulesByUuid.get(ref);
    if (rule != null) {
      if (!ruleKey.repository().equals(rule.repository()) || !ruleKey.rule().equals(rule.key())) {
        throw new IllegalArgumentException(format(
          "Specified RuleKey '%s' is not equal to the one already registered in repository for ref %s: '%s'",
          ruleKey, ref, RuleKey.of(rule.repository(), rule.key())));
      }
      return rule;
    }

    rule = new Rule(ref, ruleKey.repository(), ruleKey.rule());
    rulesByUuid.put(ref, rule);
    return rule;
  }
@Test
  public void register_returns_Rule_object_created_from_arguments() {
    for (int i = 0; i < someRandomInt(); i++) {
      String repository = SOME_REPOSITORY + i;
      String ruleKey = String.valueOf(i);
      Rule rule = underTest.register(Integer.toString(i), RuleKey.of(repository, ruleKey));
      assertThat(rule.ref()).isEqualTo(Integer.toString(i));
      assertThat(rule.repository()).isEqualTo(repository);
      assertThat(rule.key()).isEqualTo(ruleKey);
    }
  }