@Test
  public void add_tags() throws Exception {
    String ruleKey = "squid:AvoidCycle";
    Rule rule = createStandardRule();
    when(rules.findByKey(RuleKey.of("squid", "AvoidCycle"))).thenReturn(rule);

    MockUserSession.set().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
    WsTester.TestRequest request =
        tester.newRequest("add_tags").setParam("key", ruleKey).setParam("tags", "tag1,tag2");
    request.execute().assertNoContent();

    ArgumentCaptor<Object> newTagsCaptor = ArgumentCaptor.forClass(Object.class);
    verify(rules).updateRuleTags(isA(Integer.class), newTagsCaptor.capture());
    Object newTags = newTagsCaptor.getValue();
    assertThat(newTags).isInstanceOf(List.class);
    assertThat((List<String>) newTags).hasSize(4).containsOnly("admin1", "admin2", "tag1", "tag2");
  }
 @CheckForNull
 private Rule findRule(RuleKey ruleKey) {
   // TODO remove this when manual rules when be indexed in E/S
   if (ruleKey.repository().equals(Rule.MANUAL_REPOSITORY_KEY)) {
     org.sonar.api.rules.Rule rule = ruleFinder.findByKey(ruleKey);
     if (rule != null) {
       RulePriority severity = rule.getSeverity();
       return new Rule.Builder()
           .setKey(rule.getKey())
           .setRepositoryKey(rule.getRepositoryKey())
           .setName(rule.getName())
           .setDescription(rule.getDescription())
           .setSeverity(severity != null ? severity.name() : null)
           .setStatus(rule.getStatus())
           .setCreatedAt(rule.getCreatedAt())
           .setUpdatedAt(rule.getUpdatedAt())
           .build();
     }
     return null;
   } else {
     return rules.findByKey(ruleKey);
   }
 }