static boolean applyTags(RuleDto rule, Set<String> tags) {
    for (String tag : tags) {
      RuleTagFormat.validate(tag);
    }

    Set<String> initialTags = rule.getTags();
    final Set<String> systemTags = rule.getSystemTags();
    Set<String> withoutSystemTags = Sets.filter(tags, input -> input != null && !systemTags.contains(input));
    rule.setTags(withoutSystemTags);
    return withoutSystemTags.size() != initialTags.size() || !withoutSystemTags.containsAll(initialTags);
  }
@Test
  public void applyTags_validate_format() {
    RuleDto rule = new RuleDto();
    boolean changed = RuleTagHelper.applyTags(rule, Sets.newHashSet("java8", "security"));
    assertThat(rule.getTags()).containsOnly("java8", "security");
    assertThat(changed).isTrue();

    try {
      RuleTagHelper.applyTags(rule, Sets.newHashSet("Java Eight"));
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e.getMessage()).startsWith("Entry 'Java Eight' is invalid");
    }
  }