Announcement Announcement Module
Collapse
No announcement yet.
Validator - Junit question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validator - Junit question

    Hello,

    I am writing junit test for validators. Below code works:

    Code:
           // initialize errors
            errors = createNiceMock(BindingResult.class);
            errors.rejectValue("orgId", "mismatch.LaunchQueryForm.orgId");
    
            // activate the mock
            replay(errors);
    
            // go ahead and run validate now
            launchQueryValidator.validate(launchQueryForm, errors);
    
            // verify the errors
            verify(errors);
    However below doesn't work in junit - the difference here is that i am sending an additional parameter to display in the error message, Any idea how to write junit for this?
    Code:
            errors.rejectValue("typeInput", "mismatch.LaunchQueryForm.typeInput",
                               new Object[]
                    { launchQueryForm.getTypeInput() }, null);
    Error i get in this case is:
    Code:
    java.lang.AssertionError: 
      Expectation failure on verify:
        BindingResult.rejectValue("typeInput", "mismatch.LaunchQueryForm.typeInput", ["X"], null): expected: 1, actual: 0
    Thanks in advance for looking into this.

    Best,
    Prasad
Working...
X