Issue
I have a GWT app, where I take input from textbox, check that value for a regex, and if it matches, then I add that text to the table. When I give any correct input for e.g. "Hello", it works perfectly fine.
However when I try to use mockito to test this method, and pass the same string "Hello" through 'when,thenreturn ' method, then it fails the regex. cant understand whats hapenning The mocking code is :
when(mockView.getNewSymbolText()).thenReturn("Hello");
when(mockView.flexTableRowCount()).thenReturn(1);
stockWatcherPresenter.addStock();
assertEquals(1,stockWatcherPresenter.getStockSize());
Any help will be appreciated.
Solution
Your regex does not include lowercase letters. If you want to include lowercase then add that range to the character class definition. Otherwise, it is behaving as expected.
EDIT - I suppose the real question is why doesn't it fail when you run the application? My suspicion is that the symbol text is being forced to upper case by the production code whereas your mocked behavior is producing mixed case.
Answered By - vsfDawg
Answer Checked By - Robin (JavaFixing Admin)