JUnit Mockito returning LinkedList instead of ArrayList -
i have been tasked figure out why junit test failing. have found instead of returning arraylist (like getdeligationsforloggedinuser supposed return, returns linkedlist "userlist".
@suppresswarnings("unchecked") @test public void test_getdelegationsforloggedinuser() { string userid="abcd"; list<string> expecteduserlist= new arraylist<string>(); expecteduserlist.add("efghi"); expecteduserlist.add("jklmn"); expecteduserlist.add("opqrs"); when(namedparameterjdbctemplate.queryforobject(anystring(),anymap(), any(rowmapper.class))).thenreturn(expecteduserlist); list<string> userlist= workflowprocessdaoimpl.getdelegationsforloggedinuser(userid); verify(namedparameterjdbctemplate, times(1)).query(sqlcaptor.capture(), namedparametermap.capture(), rowmappercaptor.capture()); assertthat(userlist, is(expecteduserlist)); assertthat(sqlcaptor.getvalue(), is(sqlconstantssysconfigv1.getinstance().get_userids_for_delegates)); }
does have idea why case?
you mock in test method queryforobject
, test on method query
.
i suppose code defines mock of function somwhere else, isn't it? result of copy/paste operation...
Comments
Post a Comment