@Test
  public void noErrorForMatchingVars() {
    String source = "Testing string with variable %1v and %2v";
    String target = "%2v and %1v included, order not relevant";
    List<String> errorList = printfVariablesValidation.validate(source, target);

    assertThat(errorList.size(), is(0));
  }
  @Test
  public void missingVarsThroughoutTarget() {
    String source = "%a variables in all parts %b of the string %c";
    String target = "Testing string with no variables";
    List<String> errorList = printfVariablesValidation.validate(source, target);

    assertThat(errorList, contains(messages.varsMissing(Arrays.asList("%a", "%b", "%c"))));
    assertThat(errorList.size(), is(1));
  }
  @Test
  public void missingVarInTarget() {
    String source = "Testing string with variable %1v";
    String target = "Testing string with no variables";
    List<String> errorList = printfVariablesValidation.validate(source, target);

    assertThat(errorList, contains(messages.varsMissing(Arrays.asList("%1v"))));
    assertThat(errorList.size(), is(1));
  }
  @Test
  public void superstringVariablesDontMatch() {
    String source = "%l %ll";
    String target = "%ll";
    List<String> errorList = printfVariablesValidation.validate(source, target);

    assertThat(errorList, contains(messages.varsMissing(Arrays.asList("%l"))));
    assertThat(errorList.size(), is(1));
  }
  @BeforeMethod
  public void init() throws IOException {
    MockitoAnnotations.initMocks(this);

    messages = Gwti18nReader.create(ValidationMessages.class);

    printfVariablesValidation =
        new PrintfVariablesValidation(ValidationId.PRINTF_VARIABLES, messages);
    printfVariablesValidation.getRules().setEnabled(true);
  }
  @Test
  public void checkWithRealWorldExamples() {
    // examples from strings in translate.zanata.org
    String source = "%s %d %-25s %r";
    String target = "no variables";
    List<String> errorList = printfVariablesValidation.validate(source, target);

    assertThat(errorList, contains(messages.varsMissing(Arrays.asList("%s", "%d", "%-25s", "%r"))));
    assertThat(errorList.size(), is(1));
  }
  @Test
  public void addedVarsThroughoutTarget() {
    String source = "Testing string with no variables";
    String target = "%1$-0lls variables in all parts %2$-0hs of the string %3$-0ls";
    List<String> errorList = printfVariablesValidation.validate(source, target);

    assertThat(
        errorList, contains(messages.varsAdded(Arrays.asList("%1$-0lls", "%2$-0hs", "%3$-0ls"))));
    assertThat(errorList.size(), is(1));
  }
  @Test
  public void bothAddedAndMissingVars() {
    String source = "String with %x and %y only, not z";
    String target = "String with %y and %z, not x";
    List<String> errorList = printfVariablesValidation.validate(source, target);

    assertThat(
        errorList,
        containsInAnyOrder(
            messages.varsAdded(Arrays.asList("%z")), messages.varsMissing(Arrays.asList("%x"))));
    assertThat(errorList.size(), is(2));
  }
 @Test
 public void idIsSet() {
   assertThat(printfVariablesValidation.getId(), is(ValidationId.PRINTF_VARIABLES));
 }